P
puzzlecracker
What's the fastests way to find a number of values in enum.
I came up with this. but I think it's over kill.
enum Type
{
VAL1,
VAL2,
VAL3
}
int Enum.GetValues(typeof(TestType)).Length;
basically, I want to list available string representation of enum
members, and comma delimit them, and skip comma after the last
element. Output should look:
VAL1, VAL2, VAL3
Here is what I have thus far:
int =0;
foreach (Type type in Enum.GetValues(typeof(Type)))
{
Console.Write(type);
if(i++< Enum.GetValues(typeof(TestType)).Length)
Console.Write(", ");
}
}
Thanks
I came up with this. but I think it's over kill.
enum Type
{
VAL1,
VAL2,
VAL3
}
int Enum.GetValues(typeof(TestType)).Length;
basically, I want to list available string representation of enum
members, and comma delimit them, and skip comma after the last
element. Output should look:
VAL1, VAL2, VAL3
Here is what I have thus far:
int =0;
foreach (Type type in Enum.GetValues(typeof(Type)))
{
Console.Write(type);
if(i++< Enum.GetValues(typeof(TestType)).Length)
Console.Write(", ");
}
}
Thanks