none
What does "+<>c" at the end of Type.Fullname mean ? RRS feed

  • Question

  • I am examining a library using reflection and I have come across some types whose FullName ends with '+<>c', I do not know what these refer to.

    I use assembly.GetTypes() to obtain an array of types in the library, the full names.

    Type[] types = assembly.GetTypes();
    
    foreach(Type type in types)
       Console.Writeline(type.FullName);

    Some of the output names look like

    NameSpace1.NameSpace2.Foo+<>c

    The type: NameSpace1.NameSpace2.Foo appears but so does NameSpace1.NameSpace2.Foo+<>c and I wish to know what this latter type represents.

    I understand that the '+' symbol in a name is used to represent a nested type and <> may have something to do with generics but the class NameSpace1.NameSpace2.Foo is not generic (it is derived from an abstract class that is also not generic).

    What kind of C# code will cause a types FullName to end with "+<>c"?

    Thank you.

    Friday, February 19, 2016 7:16 PM

Answers

  • "What does "+<>c" at the end of Type.Fullname mean ?"

    Nothing in particular. It's just a name auto-generated by the C# compiler and as such it uses "special" characters like < and > to avoid conflicts with user defined names.

    "What kind of C# code will cause a types FullName to end with "+<>c"?"

    Lambda expressions/closures for example:

        class Program {
            static int Main(string[] args) {
                return args.Count(s => s.Length > 42);
            }
        }
    

    • Marked as answer by ellipsisware Friday, February 19, 2016 9:26 PM
    Friday, February 19, 2016 9:11 PM
    Moderator