1. Use the @ symbol to precede the string to indicate that the escape character is "not" handled.
If we write a path to a file, such as the Text.txt file under the "d:/text file" path, do not add the @ symbol as follows:
string " d://text File//text.txt ";
If you use the @ symbol, it's easier:
string @" d:/text File/text.txt ";
2. Let the string cross the line
Sometimes a string is written in a single line for a long time (such as an SQL statement), not with the @ symbol, one way:
string " SELECT * from HumanResources.Employee as e " " INNER JOIN Person.Contact as C " " On E.contactid = C.contactid " " ORDER by C.lastname ";
With the @ symbol, you can change the line directly:
string @" 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 # does not allow keywords to be used as identifiers (class name, variable name, method name, tablespace name, and so on), but it is possible to add @ after it, for example:
namespace@namespace {class@class { 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"); } } }}
Transferred from: http://blog.csdn.net/chanyinhelv/article/details/6044310
C # @ Character usage