@符号的作用

 学习记录 

原文链接: https://www.cnblogs.com/cn-star/p/11872017.html

 “@”符号有如下三种作用:

  •    忽略转义字符的作用:

       例如,有时我们保存一条文件路径时;路径中“\”需要写成“\\”;第一眼看去容易让人混淆。而通过字符串前加@符号,就可以直接输入路径,忽略转义。

           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='李四'";
  •  使关键字可以作为(类名、变量名、方法名、表空间名等)使用

    

    

猜你喜欢

转载自www.cnblogs.com/susiesnai-sun/p/12814363.html
今日推荐