OpCodes.Isinst 字段

定义

测试对象引用(O 类型)是否为特定类的实例。Tests whether an object reference (type O) is an instance of a particular class.

public: static initonly System::Reflection::Emit::OpCode Isinst;
public static readonly System.Reflection.Emit.OpCode Isinst;
 staticval mutable Isinst : System.Reflection.Emit.OpCode
Public Shared ReadOnly Isinst As OpCode 

字段值

OpCode

注解

下表列出了指令的十六进制和 Microsoft 中间语言 (MSIL) 程序集格式,以及简短的参考摘要:The following table lists the instruction's hexadecimal and Microsoft Intermediate Language (MSIL) assembly format, along with a brief reference summary:

格式Format 程序集格式Assembly Format 说明Description
75 < T >75 < T > isinst classisinst class 测试对象引用是否为的实例,同时 class 返回空引用或该类或接口的实例。Tests if an object reference is an instance of class, returning either a null reference or an instance of that class or interface.

堆栈转换行为顺序如下:The stack transitional behavior, in sequential order, is:

  1. 对象引用被推送到堆栈上。An object reference is pushed onto the stack.

  2. 从堆栈中弹出对象引用并对其进行测试,以查看它是否为传入类的实例 classThe object reference is popped from the stack and tested to see if it is an instance of the class passed in class.

  3. 结果 (对象引用或空引用) 被推送到堆栈上。The result (either an object reference or a null reference) is pushed onto the stack.

Class 指示所需类的元数据标记。Class is a metadata token indicating the desired class. 如果堆栈顶部对象的类实现 class (如果是 class 一个接口) 或者是 (的派生类 class class (如果是一个常规类) ),则它将强制转换为类型,并将 class 结果推送到堆栈上,就像 Castclass 调用一样。If the class of the object on the top of the stack implements class (if class is an interface) or is a derived class of class (if class is a regular class) then it is cast to type class and the result is pushed on the stack, exactly as though Castclass had been called. 否则,在堆栈上推送空引用。Otherwise, a null reference is pushed on the stack. 如果对象引用本身为空引用,则 isinst 同样返回空引用。If the object reference itself is a null reference, then isinst likewise returns a null reference.

TypeLoadException 如果找不到类,则会引发。TypeLoadException is thrown if class cannot be found. 当 Microsoft 中间语言 (MSIL) 指令转换为本机代码而不是运行时,通常会检测到这种情况。This is typically detected when the Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at runtime.

以下 Emit 方法重载可以使用 isinst 操作码:The following Emit method overload can use the isinst opcode:

适用于