Mono Class Library: System.Enum Overview | MembersSystem.Enum.IsDefined Method |
Returns a bool indicating whether a constant with the specified value exists in the specified enumeration type. [Edit]
|
true if a constant in the enumeration described by enumType has a value equal to value; otherwise, false. [Edit]
Type Reason ArgumentNullException enumType or value is a null reference. [Edit] ArgumentException enumType is not an enumeration type.
-or-
The type of value is not an enumType or an underlying type of enumType.
[Edit]
Documentation for this section has not yet been entered. [Edit]
The following example demonstrates the Enum.IsDefined(Type, object) method.
C# Example using System; public enum Colors { Red = 1, White = 2, Blue = 4 } public class enumIsDefined { public static void Main() { Console.Write("It is {0} ", Enum.IsDefined(typeof(Colors), 1)); Console.WriteLine("that '1' is defined in 'Colors'."); Console.Write("It is {0} ", Enum.IsDefined(typeof(Colors), 3)); Console.WriteLine("that '3' is defined in 'Colors'."); } }The output is
It is True that '1' is defined in 'Colors'.
It is False that '3' is defined in 'Colors'.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0