The Enum
class has the following useful function:
public static Array GetValues(Type enumType);
How could I write something similar to give me a collection of all an enum instance's set bits? With a signature like:
public static IEnumerable<T> getFlagValues<T>(this Enum enum, T enumInstance) where T : struct;
I am having trouble getting the casting to work, as I'm not allowed to constrain by Enum
so I need to use struct
.