Retrieves the name of the constant of the specified enumeration type that has the specified value.
A string containing the name of the enumerated constant in enumType whose value is value, or a null reference if no such constant is found. If multiple constants have the same value, as to which name is returned for that value, is unspecified.
Type Reason ArgumentNullException enumType or value is a null reference. ArgumentException enumType is not a Type that describes a Enum .
-or-
value is neither of type enumType nor does it have the same underlying type as enumType.
Documentation for this section has not yet been entered.
The following example demonstrates the Enum.GetName(Type, object) method.
C# Example
using System; public enum Signs { Stop = 1, Yield = 2, Merge = 4 }; public class EnumCompTo { public static void Main() { Console.Write( "The name of the constant with the value 4 is: " ); Console.WriteLine( "{0}.", Signs.GetName(typeof(Signs), 4)); Console.Write( "The name of the constant with the value Stop is: " ); Console.WriteLine( "{0}.", Signs.GetName(typeof(Signs), Signs.Stop )); } }The output is
The name of the constant with the value 4 is: Merge.
The name of the constant with the value Stop is: Stop.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0