C# @的用法

时间:2020-08-19 19:09:36   收藏:0   阅读:113
  1. 忽略转义字符
  2. 让字符串跨行
  3. 在标识符中的用法中C#是不允许关键字作为标识符(类名、变量名、方法名、表空间名等)使用的,但如果加上@之后就可以了
 1 public void GetVal(){
 2     string s1 = "D:\\文本文件\\text.txt";
 3     string s2 = @"D:\文本文件\text.txt";// 忽略转义字符
 4     string b1 = "select * " +
 5                 "from table " +
 6                 "where 1=1";
 7     // 让字符串跨行
 8     string b2 = @"select * 
 9                 from table 
10                 where 1=1";
11     // 允许关键字作为标识符
12     string @int = "@int";
13     Console.WriteLine(@int);
14 }

 

 

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!