CodeBinaryOperatorExpression 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
代表一個由兩個表達式之間的二元運算組成的表達式。
public ref 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
[<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
- 繼承
- 屬性
範例
此範例示範如何使用 a CodeBinaryOperatorExpression 將兩個數字相加。
// 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 可用於表示包含二進位運算子的程式碼表達式。 二元運算子的例子包括等式運算子(equality (==)、加法運算子(plus (+)和位元|運算子( ()。 列 CodeBinaryOperatorType 舉代表一組基本且常用的二進位運算子,這些運算子在許多語言中都被支援。
建構函式
| 名稱 | Description |
|---|---|
| CodeBinaryOperatorExpression() |
初始化 CodeBinaryOperatorExpression 類別的新執行個體。 |
| CodeBinaryOperatorExpression(CodeExpression, CodeBinaryOperatorType, CodeExpression) |
使用指定的參數初始化類別的新實例 CodeBinaryOperatorExpression 。 |
屬性
| 名稱 | Description |
|---|---|
| Left |
取得或設定運算子左側的程式碼表達式。 |
| Operator |
取得或設定運算子在二元運算子表達式中。 |
| Right |
取得或設定運算子右側的程式碼表達式。 |
| UserData |
取得目前物件的使用者可定義資料。 (繼承來源 CodeObject) |
方法
| 名稱 | Description |
|---|---|
| Equals(Object) |
判斷指定的 物件是否等於目前的物件。 (繼承來源 Object) |
| GetHashCode() |
做為預設雜湊函式。 (繼承來源 Object) |
| GetType() |
取得目前實例的 Type。 (繼承來源 Object) |
| MemberwiseClone() |
建立目前 Object的淺層複本。 (繼承來源 Object) |
| ToString() |
傳回表示目前 物件的字串。 (繼承來源 Object) |