C# tutorial-enum |
|||||||||||||||||||||||||||
C# enumExample: enum WeekDays{Mon, Tue, Wed, Thu, Fri, Sat, Sun};
By default, the elements of the enum store values starting from 0 upward(Mon=0, Tue=1,…,Sun=6). If you do not want to accept the default values, you can change them as you like. In the case below, the values start from 1 instead of 0. enum WeekDays{Mon=1, Tue, Wed, Thu, Fri, Sat, Sun};
To access the values of the enum WeekDays, you can do as the following: int x=(int)WeekDays.Mon; Console.WriteLine("Mon={0}",x);
|
|||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||