Expression.Type Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the static type of the expression that this Expression represents.
public:
virtual property Type ^ Type { Type ^ get(); };
public:
property Type ^ Type { Type ^ get(); };
public virtual Type Type { get; }
public Type Type { get; }
member this.Type : Type
Public Overridable ReadOnly Property Type As Type
Public ReadOnly Property Type As Type
Property Value
The Type that represents the static type of the expression.
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.
// 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
' 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
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기