This documentation is archived and is not being maintained.

CodeBinaryOperatorExpression Class

Represents an expression that consists of a binary operation between two expressions.

Namespace:  System.CodeDom
Assembly:  System (in System.dll)

public class CodeBinaryOperatorExpression : CodeExpression

CodeBinaryOperatorExpression can be used to represent code expressions that include a binary operator. Some examples of binary operators are equality (==), addition (+), and bitwise (|) operators. The CodeBinaryOperatorType enumeration represents a set of basic, commonly used binary operators that are supported in many languages.

This example demonstrates use of a CodeBinaryOperatorExpression to add two numbers together.

// This CodeBinaryOperatorExpression represents the addition of 1 and 2.
CodeBinaryOperatorExpression addMethod = new CodeBinaryOperatorExpression(

    // Left operand. 
    new CodePrimitiveExpression(1),

    // CodeBinaryOperatorType enumeration value of Add.

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

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

// (1 + 2)        


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0