Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

Expression.TypeIs Method

Namespace:  System.Linq.Expressions
Assemblies:   System.Core (in System.Core.dll)
  System.Linq.Expressions (in System.Linq.Expressions.dll)

'Declaration
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.

ExceptionCondition
ArgumentNullException

expression or type is Nothing.

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
Show:
© 2015 Microsoft