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?
<> in some languages means "does not equal". But in c, the operator is != . Also note the difference between logical AND ( && ) and bitwise AND ( & ). You should use the logical operators for multiple criteria in a conditional statement.
It means "the developer probably came from BASIC and thought using a less well-known alias for a well-known operator is fine". :p.
The equal-to operator ( == ) returns true if both operands have the same value; otherwise, it returns false . The not-equal-to operator ( != ) returns true if the operands don't have the same value; otherwise, it returns false .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With