System.Linq.Expressions.FieldExpression 在哪里定义的?
Where is System.Linq.Expressions.FieldExpression defined?
遵守以下代码:
static void Main(string[] args)
{
var f = new Foo();
Expression<Func<string>> x = () => f.Bar;
MemberExpression y = (MemberExpression) x.Body;
Expression z = y.Expression;
}
class Foo
{
public string Bar { get; set; }
}
当我打破并观察 z
时,我可以看到它具有 System.Linq.Expressions.Expression
的基本类型和 System.Linq.Expressions.FieldExpression
的实际类型。
问题是我不能明确地将其转换为后者:
System.Linq.Expressions.FieldExpression z = y.Expression;
我收到一个错误
The type or namespace name 'FieldExpression' does not exist in the namespace 'System.Linq.Expressions'.
的确,在the API documentation中找不到它。
那里有对它的引用,但我调查过的那些导致链接断开或类似:
https://csharpdoc.hotexamples.com/class/System.Linq.Expressions/FieldExpression
https://www.fuget.org/packages/System.Linq.Expressions/4.3.0/lib/netstandard1.6/System.Linq.Expressions.dll/System.Linq.Expressions/FieldExpression
谁能告诉我这是怎么回事?
这是一个 internal type, derived from MemberExpression
。 public class 有一个内部派生的 class 并没有什么特别出乎意料的。
遵守以下代码:
static void Main(string[] args)
{
var f = new Foo();
Expression<Func<string>> x = () => f.Bar;
MemberExpression y = (MemberExpression) x.Body;
Expression z = y.Expression;
}
class Foo
{
public string Bar { get; set; }
}
当我打破并观察 z
时,我可以看到它具有 System.Linq.Expressions.Expression
的基本类型和 System.Linq.Expressions.FieldExpression
的实际类型。
问题是我不能明确地将其转换为后者:
System.Linq.Expressions.FieldExpression z = y.Expression;
我收到一个错误
The type or namespace name 'FieldExpression' does not exist in the namespace 'System.Linq.Expressions'.
的确,在the API documentation中找不到它。
那里有对它的引用,但我调查过的那些导致链接断开或类似:
https://csharpdoc.hotexamples.com/class/System.Linq.Expressions/FieldExpression https://www.fuget.org/packages/System.Linq.Expressions/4.3.0/lib/netstandard1.6/System.Linq.Expressions.dll/System.Linq.Expressions/FieldExpression
谁能告诉我这是怎么回事?
这是一个 internal type, derived from MemberExpression
。 public class 有一个内部派生的 class 并没有什么特别出乎意料的。