When .NET assemblies are compiled, which classes have x__ in their names?

For instance:

  • StudentRegistrationService<>c__DisplayClass1
  • <>f__AnonymousType56`2
  • DocShareClassification<GetErrors>d__2

I am sure that it StudentRegistrationService<>c__DisplayClass1is a closure, and <>f__AnonymousType56`2was generated when an anonymous type was specified, but I have never seen a class d__before. Is there more than just these?

+3
source share
3 answers

These are classes that are generated by the C # compiler to support at least the following functions.

  • Closing / Anonymous Method Expressions
  • Anonymous types
  • iterators

d__2 one probably helps the iterator class.

+6
source

This is during compilation of created classes created using anonymous types

+1
source

IIRC are the classes generated for iterator blocks. However, you must make any assumptions about these names or rely on them - these are implementation details and are subject to change at any time.

0
source

Source: https://habr.com/ru/post/1760318/


All Articles