C# | Type.IsEnumDefined() Method Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Type.IsEnumDefined(Object) Method is used to return a value which indicates whether the specified value exists in the current enumeration type. Syntax: public virtual bool IsEnumDefined (object value); Here, it takes the value to be tested. Return Value: This method returns true if the specified value is a member of the current enumeration type otherwise, false. Exceptions: ArgumentException: If the current type is not an enumeration. ArgumentNullException: If the value is null. InvalidOperationException: If the value is of a type that cannot be the underlying type of an enumeration. Below programs illustrate the use of Type.IsEnumDefined(Object) Method: Example 1: csharp // C# program to demonstrate the // Type.IsEnumDefined(Object) Method using System; using System.Globalization; using System.Reflection; class GFG { // defining enum enu public enum enu {A, B, C}; // Main Method public static void Main() { // try-catch block for handling Exception try { // creating and initializing object Type object value = enu.A; // checking for the current enumeration type // by using IsEnumDefined() Method bool status = typeof(enu).IsEnumDefined(value); // display the result if (status) Console.WriteLine("specified value is a member"+ " of the current enumeration type"); else Console.WriteLine("specified value is not"+ " present in the current enumeration type"); } // catch ArgumentNullException here catch (ArgumentNullException e) { Console.WriteLine("Object is null."); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } // catch ArgumentNullException here catch (InvalidOperationException e) { Console.WriteLine("Object is null."); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } // catch ArgumentException here catch (ArgumentException e) { Console.WriteLine("Object is null."); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: specified value is a member of the current enumeration type Example 2: csharp // C# program to demonstrate the // Type.IsEnumDefined(Object) Method using System; using System.Globalization; using System.Reflection; class GFG { // defining enum enu public enum enu {A, B, C}; // Main Method public static void Main() { // try-catch block for handling Exception try { // creating and initializing object Type object value = enu.B; // checking for the current enumeration type // by using IsEnumDefined() Method bool status = typeof(int).IsEnumDefined(value); // display the result if (status) Console.WriteLine("specified value is a member"+ " of the current enumeration type"); else Console.WriteLine("specified value is not"+ " present in the current enumeration type"); } // 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: csharp // C# program to demonstrate the // Type.IsEnumDefined(Object) Method using System; using System.Globalization; using System.Reflection; class GFG { // defining enum enu public enum enu {A, B, C}; // Main Method public static void Main() { // try-catch block for handling Exception try { // creating and initializing object Type object value = null; // checking for the current enumeration type // by using IsEnumDefined() Method bool status = typeof(enu).IsEnumDefined(value); // display the result if (status) Console.WriteLine("specified value is a member"+ " of the current enumeration type"); else Console.WriteLine("specified value is not"+ " present in the current enumeration type"); } // 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.isenumdefined?view=netframework-4.8 Comment More infoAdvertise with us Next Article C# | Type.GetEnumNames() Method R rohitprasad3 Follow Improve Article Tags : C# CSharp-method CSharp-Type-Class Similar Reads C# | Type.GetEnumName() Method 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 th 3 min read 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.GetEnumUnderlyingType() Method Type.GetEnumUnderlyingType() Method is used to return the underlying type of the current enumeration type. Syntax: public virtual Type GetEnumUnderlyingType (); Return Value: This method returns the underlying type of the current enumeration. Exception: This method will return the ArgumentException 2 min read C# | Type.GetInterface() Method Type.GetInterface() Method is used to gets a specific interface implemented or inherited by the current Type. GetInterface(String) Method This method is used to search for the interface with the specified name. Syntax: public Type GetInterface (string name); Here, it takes the string containing the 4 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 Like