Export (0) Print
Expand All

Expression.MakeBinary Method (ExpressionType, Expression, Expression)

Creates a BinaryExpression, given the left and right operands, by calling an appropriate factory method.

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

public static BinaryExpression MakeBinary(
	ExpressionType binaryType,
	Expression left,
	Expression right
)

Parameters

binaryType
Type: System.Linq.Expressions.ExpressionType
The ExpressionType that specifies the type of binary operation.
left
Type: System.Linq.Expressions.Expression
An Expression that represents the left operand.
right
Type: System.Linq.Expressions.Expression
An Expression that represents the right operand.

Return Value

Type: System.Linq.Expressions.BinaryExpression
The BinaryExpression that results from calling the appropriate factory method.

ExceptionCondition
ArgumentException

binaryType does not correspond to a binary expression node.

ArgumentNullException

left or right is null.

The binaryType parameter determines which BinaryExpression factory method this method calls. For example, if binaryType is Subtract, this method invokes Subtract.

The following example demonstrates how to use the MakeBinary(ExpressionType, Expression, Expression) method to create a BinaryExpression 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)


.NET Framework

Supported in: 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Community Additions

ADD
Show:
© 2014 Microsoft