常用的转义字符有如下图:
通过查找搜索及验证,共发现“@”符号有如下三种作用:
①.忽略转义字符的作用:例如,有时我们保存一条文件路径时;路径中“\”需要写成“\\”;第一眼看去容易让人混淆。而通过字符串前加“@”符号,就可以直接输入路径,忽略转义。
string sPath = "D:\\192.168.12.34\\USER\\LOCAL.jpg"; string sPathV = @"D:\192.168.12.34\USER\LOCAL.jpg";
输出结果为:
②.让字符串跨行
未加“@”前:
string str = "select * from U_Wippackage_notice " + "where id=‘123456‘" + " and name=‘张三‘";
加了“@”后:
string str1 = @"select * from U_Wippackage_notice where id=‘123456‘ and name=‘李四‘";
③.使关键字可以作为(类名、变量名、方法名、表空间名等)使用
原文:https://www.cnblogs.com/cn-star/p/11872017.html