EnumExtensions.cs 576 B

1234567891011121314151617181920
  1. // -----------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. // -----------------------------------------------------------------------
  4. #if !CLR40
  5. using System;
  6. namespace System
  7. {
  8. public static class EnumExtensions
  9. {
  10. public static bool HasFlag(this Enum enumRef, Enum flag)
  11. {
  12. long value = Convert.ToInt64(enumRef);
  13. long flagVal = Convert.ToInt64(flag);
  14. return (value & flagVal) == flagVal;
  15. }
  16. }
  17. }
  18. #endif