C# | Type.GetEnumName() Method Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Type.GetEnumName(Object) Method is used to return the name of the constant which has the specified value for the current enumeration type. Syntax: public virtual string GetEnumName (object value); Here, it takes the value whose name is to be retrieved.Return Value: This method returns the name of the member of the current enumeration type which has the specified value. If no such constant is found then it will return null.Exceptions: ArgumentException: If the current type is not an enumeration or value is neither of the current type nor does it have the same underlying type as the current type.ArgumentNullException: If value is null. Below programs illustrate the use of the above-discussed method:Example 1: csharp // C# program to demonstrate the // Type.GetEnumName(Object) Method using System; using System.Globalization; using System.Reflection; class GFG { // Defining enum ABC enum ABC {A, B, C} // Main Method public static void Main() { // Creating try-catch block // to handle exceptions try { // Creating and initializing object // of ABC with instance of enum ABC ABC a = ABC.A; // Declaring and initializing // object of Type Type type = a.GetType(); string obj = type.GetEnumName(a); Console.WriteLine("Name of constant is: " + obj); } // catch ArgumentNullException here catch (ArgumentNullException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: Name of constant is: A Example 2: For ArgumentException csharp // C# program to demonstrate the // Type.GetEnumName(Object) Method using System; using System.Globalization; using System.Reflection; class GFG { // Defining enum ABC enum ABC {A, B, C} // Main Method public static void Main() { // Creating try-catch block // to handle exceptions try { // Creating and initializing object // of ABC with instance of enum ABC ABC a = ABC.A; // Declaring and initializing // object of Type Type type = typeof(int); string obj = type.GetEnumName(a); Console.WriteLine("Name of constant is: " + obj); } // catch ArgumentNullException here catch (ArgumentNullException e) { Console.WriteLine("value is null. "); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } // catch ArgumentException here catch (ArgumentException e) { Console.WriteLine("The current type is not an Enumeration."); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: The current type is not an Enumeration. Exception Thrown: System.ArgumentException Example 3: For ArgumentNullException csharp // C# program to demonstrate the // Type.GetEnumName(Object) Method using System; using System.Globalization; using System.Reflection; class GFG { // Defining enum ABC enum ABC {A, B, C} // Main Method public static void Main() { // Creating try-catch block // to handle exceptions try { // Creating and initializing object // of ABC with instance of enum ABC ABC a = ABC.A; // Declaring and initializing // object of Type Type type = typeof(int); string obj = type.GetEnumName(null); Console.WriteLine("Name of constant is " + obj); } // catch ArgumentNullException here catch (ArgumentNullException e) { Console.WriteLine("value is null. "); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } // catch ArgumentException here catch (ArgumentException e) { Console.WriteLine("The current type is not an Enumeration."); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: value is null. Exception Thrown: System.ArgumentNullException Reference: https://learn.microsoft.com/en-us/dotnet/api/system.type.getenumname?view=netframework-4.8 Comment More infoAdvertise with us Next Article C# | Type.GetMember() Method R rohitprasad3 Follow Improve Article Tags : C# CSharp-method CSharp-Type-Class Similar Reads C# | Type.GetEnumNames() Method Type.GetEnumNames() Method is used to return the names of the members of the current enumeration type. Syntax: public virtual string[] GetEnumNames (); Returns: This method returns an array which contains the names of the members of the enumeration.Exception: This method will give ArgumentException 2 min read C# | Type.GetEnumValues() Method Type.GetEnumValues() Method is used to return an array of the values of the constants in the current enumeration type.Syntax: public virtual Array GetEnumValues (); Return Value: This method returns an array which contains the values. The elements of the array are sorted by the binary values i.e. th 2 min read C# | Type.GetMember() Method Type.GetMember() Method is used to get the specified members of the current Type. There are 3 methods in the overload list of this method as follows: GetMember(String) Method GetMember(String, BindingFlags) Method GetMember(String, MemberTypes, BindingFlags) Method GetMember(String) Method This meth 6 min read C# | Type.GetMembers() Method Type.GetMembers() Method is used to get the members (properties, methods, fields, events, and so on) of the current Type. There are 2 methods in the overload list of this method as follows: GetMembers() Method GetMembers(BindingFlags) Method GetMembers() Method This method is used to return all the 4 min read C# | Type.GetDefaultMembers() Method Type.GetDefaultMembers() Method is used to find the members defined for the current Type whose DefaultMemberAttribute is set. Syntax: public virtual System.Reflection.MemberInfo[] GetDefaultMembers (); Return Value: This method returns an array of MemberInfo objects representing all default members 2 min read C# | Type.GetElementType() Method Type.GetElementType() Method is used to return the Type of the object encompassed or referred to by the current array, pointer or reference type when overridden in a derived class. Syntax: public abstract Type GetElementType (); Return Value: This method returns the Type of the object encompassed or 2 min read Like