OpCode.Value 属性

定义

获取中间语言 (IL) 指令的数值。

public:
 property short Value { short get(); };
public short Value { get; }
member this.Value : int16
Public ReadOnly Property Value As Short

属性值

只读。 IL 指令的数值。

示例

以下示例显示 指令的 OpCodes.Add 属性值。

using System;
using System.Reflection;
using System.Reflection.Emit;

public class Example
{
   public static void Main()
   {
      OpCode op = OpCodes.Add;
      foreach (var prp in op.GetType().GetProperties())
         Console.WriteLine("{0} ({1}): {2}", prp.Name,
                           prp.PropertyType.Name, prp.GetValue(op));
   }
}
// The example displays the following output:
//       OperandType (OperandType): InlineNone
//       FlowControl (FlowControl): Next
//       OpCodeType (OpCodeType): Primitive
//       StackBehaviourPop (StackBehaviour): Pop1_pop1
//       StackBehaviourPush (StackBehaviour): Push1
//       Size (Int32): 1
//       Value (Int16): 88
//       Name (String): add
Imports System.Reflection
Imports System.Reflection.Emit

Module Example
   Public Sub Main()
      Dim op As OpCode = OpCodes.Add
      For Each prp In op.GetType().GetProperties()
         Console.WriteLine("{0} ({1}): {2}", prp.Name, 
                           prp.PropertyType.Name, prp.GetValue(op))
      Next
   End Sub
End Module
' The example displays the following output:
'       OperandType (OperandType): InlineNone
'       FlowControl (FlowControl): Next
'       OpCodeType (OpCodeType): Primitive
'       StackBehaviourPop (StackBehaviour): Pop1_pop1
'       StackBehaviourPush (StackBehaviour): Push1
'       Size (Int32): 1
'       Value (Int16): 88
'       Name (String): add

注解

属性 Name 返回与指令的数值相对应的字符串名称。

适用于