Expression.ExclusiveOr メソッド

定義

ビットごとの BinaryExpression 演算を表す XOR を作成します。

オーバーロード

ExclusiveOr(Expression, Expression, MethodInfo)

ユーザー定義型の BinaryExpression を使用して、ビットごとの XOR 演算を表す op_ExclusiveOr を作成します。 実装メソッドを指定できます。

ExclusiveOr(Expression, Expression)

ユーザー定義型の BinaryExpression を使用して、ビットごとの XOR 演算を表す op_ExclusiveOr を作成します。

ExclusiveOr(Expression, Expression, MethodInfo)

ソース:
BinaryExpression.cs
ソース:
BinaryExpression.cs
ソース:
BinaryExpression.cs

ユーザー定義型の BinaryExpression を使用して、ビットごとの XOR 演算を表す op_ExclusiveOr を作成します。 実装メソッドを指定できます。

public:
 static System::Linq::Expressions::BinaryExpression ^ ExclusiveOr(System::Linq::Expressions::Expression ^ left, System::Linq::Expressions::Expression ^ right, System::Reflection::MethodInfo ^ method);
public static System.Linq.Expressions.BinaryExpression ExclusiveOr (System.Linq.Expressions.Expression left, System.Linq.Expressions.Expression right, System.Reflection.MethodInfo method);
public static System.Linq.Expressions.BinaryExpression ExclusiveOr (System.Linq.Expressions.Expression left, System.Linq.Expressions.Expression right, System.Reflection.MethodInfo? method);
static member ExclusiveOr : System.Linq.Expressions.Expression * System.Linq.Expressions.Expression * System.Reflection.MethodInfo -> System.Linq.Expressions.BinaryExpression
Public Shared Function ExclusiveOr (left As Expression, right As Expression, method As MethodInfo) As BinaryExpression

パラメーター

left
Expression

Expression プロパティを等しく設定する Left

right
Expression

Expression プロパティを等しく設定する Right

method
MethodInfo

MethodInfo プロパティを等しく設定する Method

戻り値

BinaryExpression と等しい NodeType プロパティと、指定した値に設定された ExclusiveOrLeft、および Right の各プロパティを含む Method

例外

left または rightnull です。

methodnull ではなく、それを表すメソッドは void を返し、static (Visual Basic では Shared) ではなく、またはちょうど 2 つの引数を受け取りません。

methodnull で、left.Type および right.Type には XOR 演算子が定義されていません。

注釈

結果 BinaryExpression の プロパティは、 Method 実装メソッドに設定されます。 プロパティは Type ノードの型に設定されます。 ノードがリフトされた場合、 IsLifted プロパティと IsLiftedToNull プロパティは両方とも trueになります。 それ以外の場合は です falseConversion プロパティが null です。

次の情報では、実装メソッド、ノードの種類、およびノードがリフトされるかどうかについて説明します。

メソッドの実装

次の規則によって、操作の選択した実装方法が決まります。

  • が でなくnullstatic 2 つの引数を受け取る void 以外の (SharedVisual Basic では) メソッドを表す場合methodは、実装メソッドです。

  • それ以外の場合、 Type または right のいずれかの left プロパティが演算子をオーバーロードするユーザー定義型をXOR表す場合、MethodInfoそのメソッドを表す は実装メソッドです。

  • それ以外の場合 leftは 。と 入力します right。型は整数型またはブール型で、実装メソッドは です null

ノードの種類とリフトされたノードと非リフト

実装メソッドが でない null場合:

  • の場合 left。と 入力します right。型は実装メソッドの対応する引数型に割り当て可能であり、ノードはリフトされません。 ノードの型は、実装メソッドの戻り値の型です。

  • 次の 2 つの条件が満たされた場合、ノードはリフトされ、ノードの型は実装メソッドの戻り値の型に対応する null 許容型です。

    • left.と 入力します right。型はどちらも、少なくとも 1 つが null 許容であり、対応する null 非許容型が実装メソッドの対応する引数型と等しい値型です。

    • 実装メソッドの戻り値の型は null 非許容値型です。

実装メソッドが の場合:null

  • の場合 left。と 入力します right。型はどちらも null 非許容であり、ノードはリフトされません。 ノードの型は、定義済みの XOR 演算子の結果の型です。

  • の場合 left。と 入力します right。型はどちらも null 許容であり、ノードはリフトされます。 ノードの型は、定義済みの XOR 演算子の結果の型に対応する null 許容型です。

適用対象

ExclusiveOr(Expression, Expression)

ソース:
BinaryExpression.cs
ソース:
BinaryExpression.cs
ソース:
BinaryExpression.cs

ユーザー定義型の BinaryExpression を使用して、ビットごとの XOR 演算を表す op_ExclusiveOr を作成します。

public:
 static System::Linq::Expressions::BinaryExpression ^ ExclusiveOr(System::Linq::Expressions::Expression ^ left, System::Linq::Expressions::Expression ^ right);
public static System.Linq.Expressions.BinaryExpression ExclusiveOr (System.Linq.Expressions.Expression left, System.Linq.Expressions.Expression right);
static member ExclusiveOr : System.Linq.Expressions.Expression * System.Linq.Expressions.Expression -> System.Linq.Expressions.BinaryExpression
Public Shared Function ExclusiveOr (left As Expression, right As Expression) As BinaryExpression

パラメーター

left
Expression

Expression プロパティを等しく設定する Left

right
Expression

Expression プロパティを等しく設定する Right

戻り値

BinaryExpression と等しい NodeType プロパティと、指定した値に設定された ExclusiveOr プロパティおよび Left プロパティを含む Right

例外

left または rightnull です。

XOR 演算子は、left.Type および right.Type に対して定義されていません。

次のコード例は、論理 XOR 操作を表す式を作成する方法を示しています。

// Add the following directive to your file:
// using System.Linq.Expressions;

// This expression represents an exclusive OR operation for its two arguments.
// Both arguments must be of the same type,
// which can be either integer or boolean.

Expression exclusiveOrExpr = Expression.ExclusiveOr(
    Expression.Constant(5),
    Expression.Constant(3)
);

// Print out the expression.
Console.WriteLine(exclusiveOrExpr.ToString());

// The following statement first creates an expression tree,
// then compiles it, and then executes it.
Console.WriteLine(
    Expression.Lambda<Func<int>>(exclusiveOrExpr).Compile()());

// The XOR operation is performed as follows:
// 101 xor 011 = 110

// This code example produces the following output:
//
// (5 ^ 3)
// 6
' Add the following directive to your file:
' Imports System.Linq.Expressions   

' This expression represents an exclusive OR operation for its two arguments.
' Both arguments must be of the same type, 
' which can be either integer or Boolean.

Dim exclusiveOrExpr As Expression = Expression.ExclusiveOr(
     Expression.Constant(5),
     Expression.Constant(3)
 )

' Print the expression.
Console.WriteLine(exclusiveOrExpr.ToString())

' The following statement first creates an expression tree,
' then compiles it, and then executes it.           
Console.WriteLine(
    Expression.Lambda(Of Func(Of Integer))(exclusiveOrExpr).Compile()())

' The XOR operation is performed as follows:
' 101 xor 011 = 110

' This code example produces the following output:
'
' (5 ^ 3)
' 6

注釈

結果 BinaryExpression の プロパティは、 Method 実装メソッドに設定されます。 プロパティは Type ノードの型に設定されます。 ノードがリフトされた場合、 IsLifted プロパティと IsLiftedToNull プロパティは両方とも trueになります。 それ以外の場合は です falseConversion プロパティが null です。

次の情報では、実装メソッド、ノードの種類、およびノードがリフトされるかどうかについて説明します。

メソッドの実装

次の規則は、操作の実装方法を決定します。

  • または right のいずれかの left プロパティがType演算子をオーバーロードするユーザー定義型をXOR表す場合、MethodInfoそのメソッドを表す は実装メソッドです。

  • それ以外の場合 leftは 。と 入力します right。型は整数型またはブール型で、実装メソッドは です null

ノードの種類とリフトされたノードと非リフト

実装メソッドが でない null場合:

  • の場合 left。と 入力します right。型は実装メソッドの対応する引数型に割り当て可能であり、ノードはリフトされません。 ノードの型は、実装メソッドの戻り値の型です。

  • 次の 2 つの条件が満たされた場合、ノードはリフトされ、ノードの型は実装メソッドの戻り値の型に対応する null 許容型です。

    • left.と 入力します right。型はどちらも、少なくとも 1 つが null 許容であり、対応する null 非許容型が実装メソッドの対応する引数型と等しい値型です。

    • 実装メソッドの戻り値の型は null 非許容値型です。

実装メソッドが の場合:null

  • の場合 left。と 入力します right。型はどちらも null 非許容であり、ノードはリフトされません。 ノードの型は、定義済みの XOR 演算子の結果の型です。

  • の場合 left。と 入力します right。型はどちらも null 許容であり、ノードはリフトされます。 ノードの型は、定義済みの XOR 演算子の結果の型に対応する null 許容型です。

適用対象