I have a class called Questions
(plural). In this class there is an enum called Question
(singular) which looks like this.
public e
Since enums can be declared with multiple primitive types, a generic extension method to cast any enum type can be useful.
enum Box
{
HEIGHT,
WIDTH,
DEPTH
}
public static void UseEnum()
{
int height = Box.HEIGHT.GetEnumValue();
int width = Box.WIDTH.GetEnumValue();
int depth = Box.DEPTH.GetEnumValue();
}
public static T GetEnumValue(this object e) => (T)e;