C# Type GetEnumName
Description
Type GetEnumName
returns the name of the constant that
has the specified value, for the current enumeration type.
Syntax
Type.GetEnumName
has the following syntax.
public virtual string GetEnumName(
Object value
)
Parameters
Type.GetEnumName
has the following parameters.
value
- The value whose name is to be retrieved.
Returns
Type.GetEnumName
method returns The name of the member of the current enumeration type that has the specified
value, or null if no such constant is found.
Example
/*from ww w . j a v a 2 s . c om*/
using System;
enum ABC { A, B, C }
public class MainClass
{
public static void Main(String[] argv)
{
ABC a = ABC.A;
System.Console.WriteLine(a.GetType().GetEnumName(a));
}
}
The code above generates the following result.