简体   繁体   English

C#反射Type.Name仅由非通用类上的通用括号组成

[英]C# Reflection Type.Name consists solely of generic brackets on non-generic class

I have a class in an assembly I am reflecting through: 我正在反映的程序集中有一个课程:

public class Example
{
    public List<int> things;
}

When reflecting over the assembly and grabbing type.Name: 反映装配和抓取类型时,名称:

foreach(var type in typeof(Example).Assembly.GetTypes())
    var hold = type.Name;

What is stored in the variable hold is just generic brackets, <> , and the type.FullName is Example+<> . 存储在变量hold中的只是通用括号<>和type.FullName是Example+<> What is going on? 到底是怎么回事? This works with every other class in the assembly. 这适用于装配中的所有其他类。 This class does have two partial files, neither define it to be generic though. 此类确实有两个部分文件,但都没有将其定义为通用文件。

These types are generated by the compiler to help make your code work. 这些类型由编译器生成,以帮助使您的代码正常工作。

They come from lambdas, iterators, or anonymous types. 它们来自lambda,迭代器或匿名类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM