Expression.ExclusiveOr Metoda

Definice

Vytvoří BinaryExpression bitové XOR operace.

Přetížení

ExclusiveOr(Expression, Expression, MethodInfo)

Vytvoří operaci BinaryExpression , která představuje bitové XOR operace, pomocí op_ExclusiveOr pro uživatelem definované typy. Je možné zadat metodu implementace.

ExclusiveOr(Expression, Expression)

Vytvoří operaci BinaryExpression , která představuje bitové XOR operace, pomocí op_ExclusiveOr pro uživatelem definované typy.

ExclusiveOr(Expression, Expression, MethodInfo)

Zdroj:
BinaryExpression.cs
Zdroj:
BinaryExpression.cs
Zdroj:
BinaryExpression.cs

Vytvoří operaci BinaryExpression , která představuje bitové XOR operace, pomocí op_ExclusiveOr pro uživatelem definované typy. Je možné zadat metodu implementace.

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

Parametry

left
Expression

Vlastnost Expression se má nastavit Left na rovnou.

right
Expression

Vlastnost Expression se má nastavit Right na rovnou.

method
MethodInfo

A MethodInfo , aby se vlastnost nastavil Method na hodnotu rovna.

Návraty

Vlastnost BinaryExpression , která má NodeType vlastnost rovna ExclusiveOr a Leftvlastnosti , Righta Method nastavené na zadané hodnoty.

Výjimky

left nebo right je null.

method není null a metoda, která představuje, vrátí void, není static (Shared v jazyce Visual Basic) nebo nepřebírají přesně dva argumenty.

method is null a XOR operátor není definován pro left. Zadejte a right. Typ.

Poznámky

Výsledná BinaryExpression vlastnost má nastavenou Method na implementovací metodu. Vlastnost Type je nastavena na typ uzlu. Pokud je uzel zvednutí, IsLifted vlastnosti a IsLiftedToNull jsou .true V opačném případě jsou false. Vlastnost Conversion je null.

Následující informace popisují metodu implementace, typ uzlu a to, jestli se uzel zvedne.

Implementace metody

Zvolenou metodu implementace pro operaci určují následující pravidla:

  • Pokud method není null a představuje metodu bez void ( staticShared v jazyce Visual Basic), která přijímá dva argumenty, je to implementovaná metoda.

  • V opačném případě, pokud Type vlastnost nebo leftright představuje uživatelem definovaný typ, který přetíží XOR operátor, MethodInfo představuje tuto metodu je implementovací metoda.

  • V opačném případě platí, že pokud left. Zadejte a right. Typy jsou integrální nebo logické typy, implementovaná metoda je null.

Typ uzlu a zrušeno vs. nezrušeno

Pokud implementovaná metoda není null:

  • Pokud left. Zadejte a right. Typy jsou přiřaditelné k odpovídajícím typům argumentů implementované metody, uzel není zvednut. Typ uzlu je návratový typ implementační metody.

  • Pokud jsou splněny následující dvě podmínky, uzel se zruší a typ uzlu je typ s možnou hodnotou null, který odpovídá návratovému typu implementační metody:

    • left. Zadejte a right. Typ jsou oba typy hodnot, z nichž alespoň jeden má hodnotu null, a odpovídající typy, které nemají hodnotu null, jsou rovny odpovídajícím typům argumentů implementované metody.

    • Návratový typ implementační metody je typ hodnoty s možnou hodnotou null.

Pokud je nullimplementovaná metoda :

  • Pokud left. Zadejte a right. Oba typy nemají hodnotu null, uzel není zvednut. Typ uzlu je typ výsledku předdefinovaného operátoru XOR .

  • Pokud left. Zadejte a right. Typ má obě hodnoty null, uzel je zvednut. Typ uzlu je typ s možnou hodnotou null, který odpovídá typu výsledku předdefinovaného operátoru XOR .

Platí pro

ExclusiveOr(Expression, Expression)

Zdroj:
BinaryExpression.cs
Zdroj:
BinaryExpression.cs
Zdroj:
BinaryExpression.cs

Vytvoří operaci BinaryExpression , která představuje bitové XOR operace, pomocí op_ExclusiveOr pro uživatelem definované typy.

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

Parametry

left
Expression

Vlastnost Expression se má nastavit Left na rovnou.

right
Expression

Vlastnost Expression se má nastavit Right na rovnou.

Návraty

Vlastnost BinaryExpression a, která má NodeType vlastnost rovna ExclusiveOr a Left vlastnosti a Right nastavené na zadané hodnoty.

Výjimky

left nebo right je null.

Operátor XOR není definován pro left. Zadejte a right. Typ.

Příklady

Následující příklad kódu ukazuje, jak vytvořit výraz, který představuje logickou operaci 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

Poznámky

Výsledná BinaryExpression vlastnost má nastavenou Method na implementovací metodu. Vlastnost Type je nastavena na typ uzlu. Pokud je uzel zvednutí, IsLifted vlastnosti a IsLiftedToNull jsou .true V opačném případě jsou false. Vlastnost Conversion je null.

Následující informace popisují metodu implementace, typ uzlu a to, jestli se uzel zvedne.

Implementace metody

Následující pravidla určují metodu implementace operace:

  • Type Pokud vlastnost nebo leftright představuje uživatelem definovaný typ, který přetíží XOR operátor, MethodInfo představuje tuto metodu implementovat metodu.

  • V opačném případě platí, že pokud left. Zadejte a right. Typy jsou integrální nebo logické typy, implementovaná metoda je null.

Typ uzlu a zrušeno vs. nezrušeno

Pokud implementovaná metoda není null:

  • Pokud left. Zadejte a right. Typy jsou přiřaditelné k odpovídajícím typům argumentů implementované metody, uzel není zvednut. Typ uzlu je návratový typ implementační metody.

  • Pokud jsou splněny následující dvě podmínky, uzel se zruší a typ uzlu je typ s možnou hodnotou null, který odpovídá návratovému typu implementační metody:

    • left. Zadejte a right. Typ jsou oba typy hodnot, z nichž alespoň jeden má hodnotu null, a odpovídající typy, které nemají hodnotu null, jsou rovny odpovídajícím typům argumentů implementované metody.

    • Návratový typ implementační metody je typ hodnoty s možnou hodnotou null.

Pokud je nullimplementovaná metoda :

  • Pokud left. Zadejte a right. Oba typy nemají hodnotu null, uzel není zvednut. Typ uzlu je typ výsledku předdefinovaného operátoru XOR .

  • Pokud left. Zadejte a right. Typ má obě hodnoty null, uzel je zvednut. Typ uzlu je typ s možnou hodnotou null, který odpovídá typu výsledku předdefinovaného operátoru XOR .

Platí pro