Under this blog post we'll be discussing on " What are Enumerations ?" & creating and using new Enum types.
- What are Enumerations ???
- Initializing & Using Enums
{ Monday, Tuesday = 1, Wednesday, Thursday, Friday,
Saturday, Sunday
/* In this case, the enumeration literals Wednesday,
Thursday,Friday,Saturday and Sunday will automatically
have the values 2, 3,4,5 and 6. */
};
static void Main(string[] args)
{
// loops through the days of the week
for (Days dayOfWeek = Days.Monday; dayOfWeek <= Days.Sunday;
dayOfWeek++)
{
Console.WriteLine(dayOfWeek);
}
Console.ReadLine();
//Output is:
//Monday
//Tuesday
//Wednesday …
}
No comments:
Post a Comment