The three functions of @ in c,
Previously, I only knew that @ in C # added the @ identifier in front of the \ Escape Character for writing the file path. I didn't expect @ to have other functions.
1. Ignore escape characters
For example
String fileName = "D :\\ text file \ text.txt ";
After @ is used
String fileName = @ "D: \ text file \ text.txt ";
2. Cross-line string
For example
string strSQL = "SELECT * FROM HumanResources.Employee AS e" + " INNER JOIN Person.Contact AS c" + " ON e.ContactID = c.ContactID" + " ORDER BY c.LastName";
After @ is used
string strSQL = @"SELECT * FROM HumanResources.Employee AS e INNER JOIN Person.Contact AS c ON e.ContactID = c.ContactID ORDER BY c.LastName";
3. Usage in identifiers
C # is not allowed to use keywords as Identifiers (Class Name, variable name, method name, tablespace name, etc.), but if you add @, you can
For example
public static void @static(int @int) { if (@int > 0) { System.Console.WriteLine("Positive Integer"); } else if (@int == 0) { System.Console.WriteLine("Zero"); } else { System.Console.WriteLine("Negative Integer"); }}
Reference: http://www.2cto.com/kf/201009/74766.html