I’m studying C# and caught a piece of code that I don’t understand. I was hoping that you could clearify it for me.
CreateCustomerTask.<>c__DisplayClass0 cDisplayClass0 =
new CreateCustomerTask.<>c__DisplayClass0();
What does the <> signify? And why is there a . (dot) in front of it?
You’re looking at some decompiled code – specifically, something that was generated by the compiler.
The compiler uses
<>(this is an implementation detail) because, whilst it’s valid for a CLR identifier to start with such characters, it’s not valid in C# – so it’s guaranteed that the name will not conflict with any names in the C# code.why the compiler has generated this code varies – it can be the implementation of a lambda, or an iterator or async block, and possibly some other reasons also.
And, hopefully the other part of your question is also answered – there’s a
.in front of it for the usual reasons – to separate namespace portions, or more likely in this case, to separate the name of a nested class from the name of the enclosing class.