In C and C ++, we know there is no way to start a variable named int, because this is a reserved keyword for C/C ++, such a variable name cannot tell whether it is an int type or an int variable.
In fact, there is also such a rule in C # That a variable name cannot be a reserved keyword. For example:
In C/C ++, we can't do anything about it. You must start a non-int type, such as adding an underscore ..
Of course, this can also be done in C.
@
I read "C #3.0 in a nutshell, 3rd Edition" today to know that there was another way to add the @ symbol (I saw another @ symbol ):CopyCodeThe Code is as follows: Class @ int
{
Static void main (string [] ARGs)
{
Console. writeline (@ string. @ long );
}
}
Class @ string
{
Public static int @ long = 3;
}
Of course, the @ symbol can be added before the reserved word or before any other valid variable name:Copy codeThe Code is as follows: String @ demostr = string. empty;
Note:In the compiler, the @ symbol is automatically removed, that is, demostr and @ demostr are considered to be the same variable in the compiler.
Although C # provides this mechanism to create a variable name with reserved words, I personally think this is a bad code style. This method may confuse others who do not know this feature.