Reserved Keywords as Variable Names Using C#

By using the '@' symbol we can use reserved keywords as variables/fields.
  1. //Using @ for variable names that are keywords.
  2. var @object = new object();
  3. var @string = "Sumit";
  4. var @if = Factor();
This is not only the problem we can solve with the '@' symbol. Let's try with the following example.
Verbatim string

A String can be created as a verbatim string. Verbatim strings start with the '@' symbol. The C# compiler understands this type of string as verbatim. Basically, the '@' symbol tells the string constructor to ignore escape characters and line breaks.
In the following example, the code compiler gives an error of "Unrecognized escape sequence." We can solve this issue with '\\' or the '@' symbol.
  1. String Str1 = "";    
  2. Str1 = "\Root\Key\NewFolder";    
Solution :
  1. Str1 = "\\Root\\Key\\NewFolder";  
  2. OR  
  3. Str1 = @"\Root\Key\NewFolder";  
Happy Coding :)