简体   繁体   中英

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+<> . 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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