Demonstrate an enumeration
using System;
public class EnumDemo {
enum apple { Jonathan, GoldenDel, RedDel, Winsap,
Cortland, McIntosh };
public static void Main() {
string[] color = {
"Red",
"Yellow",
"Red",
"Red",
"Red",
"Redish Green"
};
apple i;
for(i = apple.Jonathan; i <= apple.McIntosh; i++)
Console.WriteLine(i + " has value of " + (int)i);
Console.WriteLine();
for(i = apple.Jonathan; i <= apple.McIntosh; i++)
Console.WriteLine("Color of " + i + " is " +
color[(int)i]);
}
}
Related examples in the same category