enum to string code example

Example 1: enum value to string

class Program.
static void Main(string[] args)
{
   Enum wkday = Weekday.Friday;
   Console.WriteLine("Enum string is '{0}'", wkday.ToString());
   Console.ReadKey();
}

Example 2: java enum to string

public enum MyEnum{
	SOMETHING,SOMETHING_ELSE
}
MyEnum enumObject=MyEnum.SOMETHING;
System.out.println(enumObject.toString());
System.out.println(enumObject.name());

Example 3: chsarp enum to string

class Program  
{  
    static void Main(string[] args)  
    {  
        Enum wkday = Weekday.Friday;  
        Console.WriteLine("Enum string is '{0}'", wkday.ToString());  
        Console.ReadKey();  
    }  
          
    // Enum   
    public enum Weekday  
    {  
        Monday = 0, Tuesday = 1, Wednesday = 2, Thursday = 4, Friday = 5, Saturday = 6, Sunday = 7  
    }  
}

Example 4: enum to string java

yourEnum.name()

Tags:

Misc Example