EnumExtensionsGetFlagsTEnum Method

Gets an IEnumerableT enumeration of flags, where each flags are returned as distinct values.


Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 7.1.0
public static IEnumerable<TEnum> GetFlags<TEnum>(
	this TEnum flags,
	bool onlyDefinedValues = false
where TEnum : struct, new()


flags  TEnum
A flags enum value, whose flags should be returned. It is not checked whether TEnum is really marked by FlagsAttribute.
onlyDefinedValues  Boolean  (Optional)
to return only flags that are defined in TEnum; to return also undefined flags. This parameter is optional.
Default value: .

Type Parameters

The type of the enum flags.

Return Value

A lazy-enumerated IEnumerableT instance containing each flags of flags as distinct values.

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).



The enumerator of the returned collection does not support the IEnumerator.Reset method.

See Also