Skip to content

Commit 408c009

Browse files
Update EnumExtensions.cs
1 parent f1c23fe commit 408c009

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Code/Extensions/EnumExtensions.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,13 @@ public static EnumValue<T> ToEnumValue<T>(this T enumValue) where T : struct, En
99
{
1010
return new EnumValue<T>(enumValue);
1111
}
12+
13+
public static IEnumerable<T> GetFlags<T>(this T value) where T : struct, Enum
14+
{
15+
return from T flag in Enum.GetValues(typeof(T))
16+
where Convert.ToUInt64(value) != 0
17+
where Convert.ToUInt64(flag) != 0
18+
where value.HasFlag(flag)
19+
select flag;
20+
}
1221
}

0 commit comments

Comments
 (0)