Expression.MakeBinary Method (ExpressionType, Expression, Expression)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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 Shared Function MakeBinary (
	binaryType As ExpressionType,
	left As Expression,
	right As Expression
) As BinaryExpression

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.

Exception Condition
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.
Dim binaryExpression As System.Linq.Expressions.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)

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: