Loop über Enum Values in C#

Soll über einen Enum Wert geloopt werden, kann dies so gelöst werden:

enum myEnum
{
    aa,
    bb
}
myEnum b = new myEnum();
private void IncreaseEnumValue()
{

    b++;
    if(!Enum.IsDefined(typeof(myEnum),b))
    {
        b = 0;
    }
}

This entry was posted in .Net, Code and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>