C# @的用法

  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 }

 

 

 

posted @ 2020-08-16 19:40  陨落的星尘  阅读(633)  评论(0编辑  收藏  举报