Assembly.GetTypes() returns strange type names e.g. “<>c”

后端 未结 3 1312
予麋鹿
予麋鹿 2020-12-10 10:44

When using Assembly.GetTypes() I get types that have Type.Name that begin with <>c.....

I tried to google if this is an

3条回答
  •  醉话见心
    2020-12-10 10:58

    These are compiler generated display classes. You can distinguish them by looking for the CompilerGeneratedAttribute:

    var attr = Attribute.GetCustomAttribute(type, typeof(CompilerGeneratedAttribute));
    

提交回复
热议问题