美文网首页
005_在字符串前面加上字符。

005_在字符串前面加上字符。

作者: 立秋i | 来源:发表于2018-03-30 23:32 被阅读0次

namespace _005_在字符串前面加上_字符 {

    class Program {

        static void Main(string[] args)

        {

            //当在字符串前面加上一个@字符的时候,我们就可以把一个字符串定义在多行

            // 编译器不会再去识别字符串中的转义字符

            // 如果需要在字符串中表示一个双引号的话,需要使用两个双引号

            string str1 = @"I'm a good man. 

You are bad girl!";

            Console.WriteLine(str1);

            string str2 = @"I'm a good man. \n"" You are bad girl!";

            Console.WriteLine(str2);

            //使用@字符的第二个好处

            string path = "c:\\xxx\\xx\\xxx.doc";

            Console.WriteLine(path);

            string path2 = @"c:\xxx\xx\xxx.doc";

            Console.WriteLine(path2);

            Console.ReadKey();

        }

    }

}

相关文章

网友评论

      本文标题:005_在字符串前面加上字符。

      本文链接:https://www.haomeiwen.com/subject/jcvmcftx.html