While coding in C#, I by mistake added a strudel sign before a variable in if statement (instead of exclamation mark).
bool b = false;
if (@b)
{
}
I surprised it compiled successfully without any error.
I wonder: What is the meaning of the above code?
@can be used to “escape” identifiers, in case you want to use keywords. For example:Of course it’s usually a bad idea to use keywords as identifiers, but if you’re using a class library which happens to use them, it can be hard to avoid. It can also be useful sometimes to use “@this” for situations where you want to effectively have a
thisreference, but for whatever reason you can’t use one. (These are pretty few and far between, but I’ve seen it a couple of times, and it’s worth at least knowing about.)