EnumExtensionsGetFlagsTEnum Method

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

Definition

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

Parameters

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

TEnum
The type of the enum flags.

Return Value

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

Remarks

  Note

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

See Also