Enum.IsDefined 方法
返回指定枚举中是否存在具有指定值的常数的指示。
**命名空间:**System
**程序集:**mscorlib(在 mscorlib.dll 中)
语法
声明
<ComVisibleAttribute(True)> _
Public Shared Function IsDefined ( _
enumType As Type, _
value As Object _
) As Boolean
用法
Dim enumType As Type
Dim value As Object
Dim returnValue As Boolean
returnValue = Enum.IsDefined(enumType, value)
[ComVisibleAttribute(true)]
public static bool IsDefined (
Type enumType,
Object value
)
[ComVisibleAttribute(true)]
public:
static bool IsDefined (
Type^ enumType,
Object^ value
)
/** @attribute ComVisibleAttribute(true) */
public static boolean IsDefined (
Type enumType,
Object value
)
ComVisibleAttribute(true)
public static function IsDefined (
enumType : Type,
value : Object
) : boolean
参数
- enumType
枚举类型。
- value
enumType 的常数的值或名称。
返回值
如果 enumType 的某个常数具有等于 value 的值,则为 true;否则为 false。
异常
异常类型 | 条件 |
---|---|
enumType 或 value 为 空引用(在 Visual Basic 中为 Nothing)。 |
|
enumType 不是 Enum。 - 或 - value 的类型不是 enumType。 - 或 - value 的类型不是 enumType 的基础类型。 |
|
value 不是 SByte、Int16、Int32、Int64、Byte、UInt16、UInt32、UInt64 或 String 类型。 |
平台
Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
.NET Compact Framework
受以下版本支持:2.0、1.0