Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Enum.IsDefined Method

Returns an indication whether a constant with a specified value exists in a specified enumeration.

[Visual Basic]
Public Shared Function IsDefined( _
   ByVal enumType As Type, _
   ByVal value As Object _
) As Boolean
[C#]
public static bool IsDefined(
 Type enumType,
 object value
);
[C++]
public: static bool IsDefined(
 Type* enumType,
 Object* value
);
[JScript]
public static function IsDefined(
   enumType : Type,
 value : Object
) : Boolean;

Parameters

enumType
An enumeration type.
value
The value or name of a constant in enumType.

Return Value

true if a constant in enumType has a value equal to value; otherwise, false.

Exceptions

Exception Type Condition
ArgumentNullException enumType or value is a null reference (Nothing in Visual Basic).
ArgumentException enumType is not an Enum.

-or-

The type of value is not an enumType.

-or-

The type of value is not an underlying type of enumType.

InvalidOperationException value is not type SByte, Int16, Int32, Int64, Byte, UInt16, UInt32, or UInt64, or String.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Enum Class | Enum Members | System Namespace

Show:
© 2016 Microsoft