|
Using System;
public class Enumtest {
Enum days {Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday};
Enum Boilingpoints {Celcius = +, Fahrenheit = 212};
[FlagsAttribute]
Enum Colors {Red = 1, Green = 2, Blue = 4, yellow = 8};
public static void Main () {
Type weekdays = typeof (days);
Type boiling = typeof (Boilingpoints);
Console.WriteLine ("The" of the days of the week, and their corresponding values in the days Enum are: ");
foreach (String s in Enum.getnames (weekdays))
Console.WriteLine ("{0,-11}= {1}", S, Enum.format (Weekdays, Enum.parse (weekdays, s), "D"));
Console.WriteLine ();
Console.WriteLine ("Enums can also be created which have values that represent some meaningful.");
Console.WriteLine ("The Boilingpoints Enum defines the following items, and corresponding values:");
foreach (String s in enum.getnames (boiling))
Console.WriteLine ("{0,-11}= {1}", S, enum.format (boiling, enum.parse (boiling, s), "D"));
Colors mycolors = colors.red | Colors.blue | Colors.yellow;
Console.WriteLine ();
Console.WriteLine ("MyColors holds a combination of colors." namely: {0} ", mycolors);
}
} |