通过


Expression.TypeIs(Expression, Type) 方法

定义

public:
 static System::Linq::Expressions::TypeBinaryExpression ^ TypeIs(System::Linq::Expressions::Expression ^ expression, Type ^ type);
public static System.Linq.Expressions.TypeBinaryExpression TypeIs(System.Linq.Expressions.Expression expression, Type type);
static member TypeIs : System.Linq.Expressions.Expression * Type -> System.Linq.Expressions.TypeBinaryExpression
Public Shared Function TypeIs (expression As Expression, type As Type) As TypeBinaryExpression

参数

expression
Expression

要设置的属性Expression等于的一个Expression

type
Type

一个 Type 设置为 TypeOperand 等于的属性。

返回

属性等于和属性TypeOperandExpression设置为指定值的 ATypeBinaryExpressionTypeIsNodeType

例外

expressiontypenull.

示例

下面的示例演示如何使用 TypeIs(Expression, Type) 该方法创建一个 TypeBinaryExpression 表示针对该 Int32 类型的字符串值的类型测试。

// Create a TypeBinaryExpression that represents a
// type test of the string "spruce" against the 'int' type.
System.Linq.Expressions.TypeBinaryExpression typeBinaryExpression =
    System.Linq.Expressions.Expression.TypeIs(
        System.Linq.Expressions.Expression.Constant("spruce"),
        typeof(int));

Console.WriteLine(typeBinaryExpression.ToString());

// This code produces the following output:
//
// ("spruce" Is Int32)
' Create a TypeBinaryExpression that represents a
' type test of the String "spruce" against the Int32 type.
Dim typeBinaryExpression As System.Linq.Expressions.TypeBinaryExpression = _
    System.Linq.Expressions.Expression.TypeIs( _
        System.Linq.Expressions.Expression.Constant("spruce"), _
        Type.GetType("System.Int32"))

Console.WriteLine(typeBinaryExpression.ToString())

' This code produces the following output:
'
' ("spruce" Is Int32)

注解

Type结果UnaryExpression表示Boolean的属性。

适用于