Jelytin

Hi everyone!

I know that an entry in an enumeration can be casted down to an int, but can an integer index be used to identify an entry in an enumeration as if it were an array or list I'm trying to set up a button for each day of the week using a for loop like so:

Code Snippet

for (int i = 0; i < 7; i++)

{

dayList[i].Size = new Size(75, 23);

dayList[i].Location = new Point(15 + 100 * i, 36);

dayList[i].Text = Day[i];

}

When I try the above code, it says that I'm using a type as a variable when I try to access the i'th entry of Day. The Day and DayofWeek enumerations are already built into the framework, so I'd rather not create my own array, so how do I get this to work

Thank you.



Re: Visual C# Language Enumeration Integer Access

anubisascends

Replace

Code Snippet

Day[i]

with:

Code Snippet

Enum.GetName(typeof(Day), i).ToString()