相关疑难解决方法(0)

我怎么逃避"逐字串?

我对c#有点新,我在这一点上卡住了,我有一个常规的字符串,我用它\来逃避",逃到这里意味着逃避编译器的解释",并"在屏幕上打印,而我得到预期的输出 - >

class Program
{
    static void Main(string[] args)
    {
        string s1 = "This is a \"regular\" string";
        System.Console.WriteLine(s1);
        System.Console.Read();
    }
}
Run Code Online (Sandbox Code Playgroud)

o/p - >这是一个"常规"字符串

现在,我有一个逐字字符串,我试图以与上面相同的方式逃避"使用\..-->

class Program
{
    static void Main(string[] args)
    {
        string s2 = @"This is \t a \"verbatim\" string";//this would escape \t
        System.Console.WriteLine(s2);
        System.Console.Read();
    }
}
Run Code Online (Sandbox Code Playgroud)

为什么以上不起作用?

.net c# string escaping verbatim-string

25
推荐指数
2
解决办法
1万
查看次数

标签 统计

.net ×1

c# ×1

escaping ×1

string ×1

verbatim-string ×1