I have a bunch of enumerators. I need to pass them into a function that
is designed to write all values of any enumerator to the console. For
instance...
public enum Days : int
{
Sunday = 1,
Monday,
Tuesday
}
public enum Colors : int
{
red = 1,
blue,
green
}
static void main ()
{
Disp(Colors);
}
public static void Disp(enum e)
{
string[] sa = System.Enum.GetNames(typeof(e));
foreach(string i in sa)
{
Console.Writeline(i);
}
}
I cannot do this, the compiler fails on the "enum e" parameter in a
variety of ways... is there any way to pass an enumerator? I have
tested the code with a specific Enumerator in place of e and it works
fine... but I need it to be reusable (yeah, a 3 line function!).
Any info would be great. Thanks.