In my project i have an enum
in which i store Music genres values that looks like this :
enum Genres { Rock,Pop,Disco,Sport,Talk,Metal,Hard_Rock,Electro,Classic_Rock}
Now in my code i want a foreach
loop that will do some work based on the music genre.Something like this:
foreach(Genres genre in Enum.GetValues(typeof(Genres)))
{
switch(genre)
{
case Genres.Disco:
//Do Something
break;
case Genres.Rock:
//Do Something
break;
.....
.......
}
}
What i want to do treat my enum
in the switch
case like an array.Something like this:
foreach(Genres genre in Enum.GetValues(typeof(Genres)))
{
switch(genre)
{
case Genres[0]:
//Do Something
break;
case Genres[1]:
//Do Something
break;
.....
.......
}
}
Is this possible? Thanks in advance.
EDIT
I have a ListBox in which i want to populate it with GenreItems. But for every ListBoxItem i want to have a diffent name ass i pass them in. So i make this switch in order to check the genre and case is Rock for example i set the ListBoxItem as ROCK and add it in the ListBox.