EnumExtensionsHasFlagTEnum Method
Gets whether the bits that are set in the flags parameter are set in the specified value.
Namespace: KGySoft.CoreLibrariesAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0
public static bool HasFlag<TEnum>(
this TEnum value,
TEnum flags
)
where TEnum : struct, new()
<ExtensionAttribute>
Public Shared Function HasFlag(Of TEnum As {Structure, New}) (
value As TEnum,
flags As TEnum
) As Boolean
public:
[ExtensionAttribute]
generic<typename TEnum>
where TEnum : value class, gcnew()
static bool HasFlag(
TEnum value,
TEnum flags
)
[<ExtensionAttribute>]
static member HasFlag :
value : 'TEnum *
flags : 'TEnum -> bool when 'TEnum : struct, new()
- value TEnum
- An enumeration value of TEnum type.
- flags TEnum
- A flags enum value, whose flags should be checked. It is not checked whether TEnum
is really marked by FlagsAttribute and whether all bits that are set are defined in the TEnum type.
- TEnum
- The type of the enum value.
Boolean, if
flags is zero, or when the bits that are set in
flags are set in
value;
otherwise,
.In Visual Basic and C#, you can call this method as an instance method on any object of type
TEnum. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Always specify the
TEnum generic argument when use this method; otherwise, in .NET 4.0 and above the less performant
HasFlag(Enum) method will be used.