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 ):
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:
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.
References
C # Language Specification 2.4.2 Identifiers
Http://msdn.microsoft.com/en-us/library/aa664670 (VS.71). aspx
C #3.0 in a Nutshell, 3rd Edition: 2.2.1.1. Avoiding conflicts