EnumExtensionsHasFlagTEnum Method

Gets whether the bits that are set in the flags parameter are set in the specified value.


Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 7.1.0
public static bool HasFlag<TEnum>(
	this TEnum value,
	TEnum flags
where 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.

Type Parameters

The type of the enum value.

Return Value

, if flags is zero, or when the bits that are set in flags are set in value; otherwise, .

Usage Note

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.

See Also