.NET Framework Class Library
Expression.Type Property
Gets the static type of the expression that this Expression represents.
Assembly: System.Core (in System.Core.dll)
Syntax
Visual Basic
Public Overridable ReadOnly Property Type As Type
C#
public virtual Type Type { get; }
Visual C++
public: virtual property Type^ Type { Type^ get (); }
F#
abstract Type : Type override Type : Type
Remarks
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.
Visual Basic
' Add the following directive to your file: ' Imports System.Linq.Expressions Dim constExpr As ConstantExpression = Expression.Constant(5) Console.WriteLine("NodeType: " & constExpr.NodeType.ToString()) Console.WriteLine("Type: " & constExpr.Type.ToString()) Dim binExpr As BinaryExpression = Expression.Add(constExpr, constExpr) Console.WriteLine("NodeType: " & binExpr.NodeType.ToString()) Console.WriteLine("Type: " & binExpr.Type.ToString()) ' This code example produces the following output: ' ' NodeType: Constant ' Type: System.Int32 ' NodeType: Add ' Type: System.Int32
C#
// Add the following directive to your file: // using System.Linq.Expressions; ConstantExpression constExpr = Expression.Constant(5); Console.WriteLine("NodeType: " + constExpr.NodeType); Console.WriteLine("Type: " + constExpr.Type); BinaryExpression binExpr = Expression.Add(constExpr, constExpr); Console.WriteLine("NodeType: " + binExpr.NodeType); Console.WriteLine("Type: " + binExpr.Type); // This code example produces the following output: // // NodeType: Constant // Type: System.Int32 // NodeType: Add // Type: System.Int32
Version Information
.NET Framework
Supported in: 4, 3.5.NET Framework Client Profile
Supported in: 4, 3.5 SP1Portable Class Library
Supported in: Portable Class LibraryPlatforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
See Also