Three Functions of @ on 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 eINNER JOIN Person. Contact AS cON e. ContactID = c. ContactIDORDER 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 ");}}