共用方式為


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 會傳回對應至指令數值的字串名稱。

適用於