Duration (Pacific Standard Time):
To (Pacific Standard Time):
Impact:
  • None
User Action:
  • None
.NET Framework Class Library

Expression.TypeIs Method

Namespace:  System.Linq.Expressions
Assemblies:   System.Core (in System.Core.dll)
  System.Linq.Expressions (in System.Linq.Expressions.dll)
Public Shared Function TypeIs ( _
	expression As Expression, _
	type As Type _
) As TypeBinaryExpression

Parameters

expression
Type: System.Linq.Expressions.Expression

An Expression to set the Expression property equal to.

type
Type: System.Type

A Type to set the TypeOperand property equal to.

Return Value

Type: System.Linq.Expressions.TypeBinaryExpression
A TypeBinaryExpression for which the NodeType property is equal to TypeIs and for which the Expression and TypeOperand properties are set to the specified values.
Exception Condition
ArgumentNullException

expression or type is null.

The Type property of the resulting UnaryExpression represents Boolean.

The following example demonstrates how to use the TypeIs(Expression, Type) method to create a TypeBinaryExpression that represents a type test of a string value against the Int32 type.

' 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)

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library