static IEnumerable<Enum> GetFlags(Enum input)
{
foreach (Enum value in Enum.GetValues(input.GetType()))
if (input.HasFlag(value))
yield return value;
}
More Related Contents:
- How to declare enums in C#
- Get int value from enum in C#
- What does the [Flags] Enum Attribute mean in C#?
- Create Generic method constraining T to an Enum
- JavaScriptSerializer – JSON serialization of enum as string
- Get Enum from Description attribute [duplicate]
- Anyone know a good workaround for the lack of an enum generic constraint?
- How to loop through all enum values in C#? [duplicate]
- Automatically create an Enum based on values in a database lookup table?
- Non-unique enum values
- Why switch for enum accepts implicit conversion to 0 but no for any other integer?
- How to set enum to null
- Is there a way to check if int is legal enum in C#?
- Enum.GetValues() Return Type
- Can we define implicit conversions of enums in c#?
- Parse string to enum type
- What is the default value for enum variable?
- How to prevent duplicate values in enum?
- .NET Enumeration allows comma in the last field
- Deserialize specific enum into system.enum in Json.Net
- Cast Int to Generic Enum in C#
- What to do when bit mask (flags) enum gets too large
- How to convert from System.Enum to base integer?
- C# Enums: Nullable or ‘Unknown’ Value?
- C# using numbers in an enum
- How to get enum value by string or int
- C# Enum – How to Compare Value
- Why Enum’s HasFlag method need boxing?
- Can you have multiple enum values for the same integer? [duplicate]
- MVC 5.1 Razor DisplayFor not working with Enum DisplayName