CodeBinaryOperatorExpression 類別

定義

代表在兩個運算式間的二元運算所組成的運算式。

public ref class CodeBinaryOperatorExpression : System::CodeDom::CodeExpression
public class CodeBinaryOperatorExpression : System.CodeDom.CodeExpression
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeBinaryOperatorExpression : System.CodeDom.CodeExpression
type CodeBinaryOperatorExpression = class
    inherit CodeExpression
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeBinaryOperatorExpression = class
    inherit CodeExpression
Public Class CodeBinaryOperatorExpression
Inherits CodeExpression
繼承
CodeBinaryOperatorExpression
屬性

範例

此範例示範如何使用 CodeBinaryOperatorExpression 將兩個數位相加。

// This CodeBinaryOperatorExpression represents the addition of 1 and 2.

// Right operand.
CodeBinaryOperatorExpression^ addMethod = gcnew CodeBinaryOperatorExpression( gcnew CodePrimitiveExpression( 1 ),CodeBinaryOperatorType::Add,gcnew CodePrimitiveExpression( 2 ) );

// A C# code generator produces the following source code for the preceeding example code:
// (1 + 2)
// This CodeBinaryOperatorExpression represents the addition of 1 and 2.
CodeBinaryOperatorExpression addMethod = new CodeBinaryOperatorExpression(

    // Left operand.
    new CodePrimitiveExpression(1),

    // CodeBinaryOperatorType enumeration value of Add.
    CodeBinaryOperatorType.Add,

    // Right operand.
    new CodePrimitiveExpression(2) );

// A C# code generator produces the following source code for the preceeding example code:

// (1 + 2)
' This CodeBinaryOperatorExpression represents the addition of 1 and 2.
Dim addMethod As New CodeBinaryOperatorExpression( _
   New CodePrimitiveExpression(1), _         
   CodeBinaryOperatorType.Add, _            
   New CodePrimitiveExpression(2) )        

' A Visual Basic code generator produces the following source code for the preceeding example code:	

' (1 + 2)

備註

CodeBinaryOperatorExpression 可以用來表示包含二進位運算子的程式代碼表達式。 二元運算子的一些範例是相等 (==) 、新增 (+) ,以及位 () | 運算符。 列舉 CodeBinaryOperatorType 表示許多語言支援的一組基本、常用的二進位運算符。

建構函式

CodeBinaryOperatorExpression()

初始化 CodeBinaryOperatorExpression 類別的新執行個體。

CodeBinaryOperatorExpression(CodeExpression, CodeBinaryOperatorType, CodeExpression)

使用指定的參數初始化 CodeBinaryOperatorExpression 類別的新執行個體。

屬性

Left

取得或設定運算子左方的程式碼運算式。

Operator

取得或設定二元運算子運算式的運算子。

Right

取得或設定運算子右方的程式碼運算式。

UserData

取得目前物件的使用者可定義資料。

(繼承來源 CodeObject)

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱