Type Property
Collapse the table of content
Expand the table of content

Expression.Type Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the static type of the expression that this Expression represents.

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

public virtual Type Type { get; }

Property Value

Type: System.Type
The Type that represents the static type of the expression.

The NodeType is the type of the expression tree node, whereas the Type represents the static common language runtime (CLR) type of the expression that the node represents. For example, two nodes with different node types can have the same Type, as shown in the following code example.


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

ConstantExpression constExpr = Expression.Constant(5);
outputBlock.Text += "NodeType: " + constExpr.NodeType + "\n";
outputBlock.Text += "Type: " + constExpr.Type + "\n";

BinaryExpression binExpr = Expression.Add(constExpr, constExpr);
outputBlock.Text += "NodeType: " + binExpr.NodeType + "\n";
outputBlock.Text += "Type: " + binExpr.Type + "\n";

// This code example produces the following output:
//
// NodeType: Constant
// Type: System.Int32
// NodeType: Add
// Type: System.Int32


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft