Converting an enumerated value to a string. : enum format « Data Type « C# / CSharp Tutorial






using System;

public class EnumSample {
    enum Colors {Red = 1, Blue = 2};

    public static void Main() {
        Enum myColors = Colors.Red;
        Console.WriteLine("The value of this instance is '{0}'",
           myColors.ToString());
    }
}








2.38.enum format
2.38.1.Output enum values
2.38.2.Format an enumeration.
2.38.3.Converting an enumerated value to a string.