[英]Are anonymous types in c# accessible through reflection?
由于匿名类型的名称是编译器生成的,因此可以通过反射访问它吗?
Yes. 是。 As far as the CLR/framework is concerned, they're normal types.
就CLR /框架而言,它们是正常类型。 In fact, you can do some interesting things with reflection on anonymous types...
事实上,你可以通过对匿名类型的反思来做一些有趣的事情 ......
The current C# compiler actually creates a generic type though, so that two anonymous types which both just have a "Foo" property of different types will share a generic type, but have different closed types. 当前的C#编译器实际上创建了一个泛型类型,因此两个只具有不同类型的“Foo”属性的匿名类型将共享一个泛型类型,但具有不同的封闭类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.