CodeBinaryOperatorExpression 类

定义

表示一个表达式,该表达式包含在两个表达式间进行的二进制运算。Represents an expression that consists of a binary operation between two expressions.

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

示例

此示例演示CodeBinaryOperatorExpression如何使用将两个数字相加。This example demonstrates use of a CodeBinaryOperatorExpression to add two numbers together.

// 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可用于表示包含二元运算符的代码表达式。CodeBinaryOperatorExpression can be used to represent code expressions that include a binary operator. 二元运算符的一些示例是相等 (==)、加法 (+) 和按位 (|) 运算符。Some examples of binary operators are equality (==), addition (+), and bitwise (|) operators. CodeBinaryOperatorType枚举表示一组基本的常用二元运算符, 这些运算符在多种语言中都受支持。The CodeBinaryOperatorType enumeration represents a set of basic, commonly used binary operators that are supported in many languages.

构造函数

CodeBinaryOperatorExpression()

初始化 CodeBinaryOperatorExpression 类的新实例。Initializes a new instance of the CodeBinaryOperatorExpression class.

CodeBinaryOperatorExpression(CodeExpression, CodeBinaryOperatorType, CodeExpression)

使用指定的参数初始化 CodeBinaryOperatorExpression 类的新实例。Initializes a new instance of the CodeBinaryOperatorExpression class using the specified parameters.

属性

Left

获取或设置运算符左边的代码表达式。Gets or sets the code expression on the left of the operator.

Operator

获取或设置二进制运算符表达式中的运算符。Gets or sets the operator in the binary operator expression.

Right

获取或设置运算符右边的代码表达式。Gets or sets the code expression on the right of the operator.

UserData

获取当前对象的用户可定义数据。Gets the user-definable data for the current object.

(继承自 CodeObject)

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅