Export (0) Print
Expand All

BinaryExpression Class

Represents an expression that has a binary operator.

Namespace:  System.Linq.Expressions
Assembly:  System.Core (in System.Core.dll)

public sealed class BinaryExpression : Expression

The following tables summarize the factory methods that can be used to create a BinaryExpression that has a specific node type, represented by the NodeType property. Each table contains information for a specific class of operations such as arithmetic or bitwise.

Binary Arithmetic Operations

Bitwise Operations

Node Type

Factory Method

And

And

Or

Or

ExclusiveOr

ExclusiveOr

Shift Operations

Conditional Boolean Operations

Node Type

Factory Method

AndAlso

AndAlso

OrElse

OrElse

Comparison Operations

Coalescing Operations

Node Type

Factory Method

Coalesce

Coalesce

Array Indexing Operations

Node Type

Factory Method

ArrayIndex

ArrayIndex

In addition, the MakeBinary methods can also be used to create a BinaryExpression. These factory methods can be used to create a BinaryExpression of any node type that represents a binary operation. The parameter of these methods that is of type NodeType specifies the desired node type.

The following example creates a BinaryExpression object that represents the subtraction of one number from another.

// Create a BinaryExpression that represents subtracting 14 from 53.
System.Linq.Expressions.BinaryExpression binaryExpression =
    System.Linq.Expressions.Expression.MakeBinary(
        System.Linq.Expressions.ExpressionType.Subtract,
        System.Linq.Expressions.Expression.Constant(53),
        System.Linq.Expressions.Expression.Constant(14));

Console.WriteLine(binaryExpression.ToString());

// This code produces the following output: 
// 
// (53 - 14)

System.Object
  System.Linq.Expressions.Expression
    System.Linq.Expressions.BinaryExpression

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 Server 2008 R2, Windows Server 2008, Windows Server 2003

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

Community Additions

ADD
Show:
© 2014 Microsoft