public void PrintEnum() { CustomColor color = CustomColor.Black; System.Console.WriteLine(color); System.Console.Write(System.Environment.NewLine); Array values = Enum.GetValues(typeof(CustomColor)); foreach (var value in values) { System.Console.WriteLine(value); } System.Console.Write(System.Environment.NewLine); CustomColor[] colors = EnumTest.GetEnumValues <CustomColor>(); //second way to get enum array values foreach (var c in colors) { System.Console.WriteLine(c); } System.Console.Write(System.Environment.NewLine); System.Console.WriteLine(Enum.GetName(typeof(CustomColor), 0)); System.Console.WriteLine(); System.Console.WriteLine(Enum.IsDefined(typeof(CustomColor), 59)); //should be false }
public void Run() { EnumTest enumTest = new EnumTest(); enumTest.PrintEnum(); }