C#中的@符号
1.限定字符串
用 @ 符号加在字符串前面表示其中的转义字符“不”被处理。
string fileName = "D://文本文件//text.txt";
string fileName = @"D:/文本文件/text.txt";
2.让字符串跨行
比如SQL语句,不使用@符号时:
string strSQL = "SELECT * FROM HumanResources.Employee AS e" + " INNER JOIN Person.Contact AS c" + " ON e.ContactID = c.ContactID" + " ORDER BY c.LastName";
加上@符号后就可以直接换行了:
string strSQL = @"SELECT * FROM HumanResources.Employee AS e INNER JOIN Person.Contact AS c ON e.ContactID = c.ContactID ORDER BY c.LastName";