Represents an expression that has a binary operator.
Namespace:
System.Linq.Expressions
Assembly:
System.Core (in System.Core.dll)
Visual Basic (Declaration)
Public NotInheritable Class BinaryExpression _
Inherits Expression
Dim instance As BinaryExpression
public sealed class BinaryExpression : Expression
public ref class BinaryExpression sealed : public Expression
public final class BinaryExpression extends 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
Shift Operations
Conditional Boolean Operations
Comparison Operations
Coalescing Operations
Array Indexing Operations
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.
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)
// 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
Reference