OpCodes.Leave 字段


退出受保护的代码区域,无条件将控制转移到特定目标指令。Exits a protected region of code, unconditionally transferring control to a specific target instruction.

public: static initonly System::Reflection::Emit::OpCode Leave;
public static readonly System.Reflection.Emit.OpCode Leave;
 staticval mutable Leave : System.Reflection.Emit.OpCode
Public Shared ReadOnly Leave As 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
DD < int32 >DD < int32 > 保留 targetleave target 退出受保护的代码区域。Exits a protected region of code.

没有为此指令指定堆栈转换行为。There is no stack transition behavior specified for this instruction.

@No__t-0 指令无条件地将控制转移到特定目标指令,表示为从当前指令后面的指令开头开始的4字节有符号偏移量。The leave instruction unconditionally transfers control to the specific target instruction, represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.

@No__t-0 指令类似于 @no__t 1 指令,但它可用于退出 @no__t 2、filtercatch 块,而普通的分支指令只能用在此类块中以传输控制。The leave instruction is similar to the br instruction, but it can be used to exit a try, filter, or catch block whereas the ordinary branch instructions can only be used in such a block to transfer control within it. @No__t-0 指令将清空计算堆栈,并确保执行适当的周围 @no__t 块。The leave instruction empties the evaluation stack and ensures that the appropriate surrounding finally blocks are executed.

不能使用 @no__t 0 指令退出 @no__t 块。You cannot use a leave instruction to exit a finally block. 为了简化异常处理程序的代码生成,在 catch 块内有效地使用 leave 指令将控制转移到关联的 @no__t 1 块内的任何指令。To ease code generation for exception handlers it is valid from within a catch block to use a leave instruction to transfer control to any instruction within the associated try block.

如果指令具有一个或多个前缀代码,则只能将控制转移到其中的第一个前缀。If an instruction has one or more prefix codes, control can only be transferred to the first of these prefixes.

以下 Emit 方法重载可以使用 @no__t 操作码:The following Emit method overloads can use the leave opcode:

  • ILGenerator (操作码、标签)ILGenerator.Emit(OpCode, Label)