Convert enum to string in CSharp
Description
The following code shows how to convert enum to string.
Example
using System;/*from ww w . ja va 2 s . c o m*/
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());
}
}
The code above generates the following result.