如何在c#控制台应用程序中打印双引号(")

xav*_*xav 2 c# string console-application c#-4.0

我知道c#只是在Console.WriteLine中保存双引号内的数据("当我打印时,这两个双引号被删除");

它在控制台中的输出将是:

Console.WriteLine("These two double quotes are removed when i am printed");` 
Run Code Online (Sandbox Code Playgroud)

但我想在控制台上打印的内容与双引号相同:

Console.WriteLine("These two double quotes are removed when i am printed");` 
Run Code Online (Sandbox Code Playgroud)

这该怎么做.我这样做是因为我必须将此输出写入双引号具有重要性的文件.

use*_*620 12

您需要使用\以下命令转义字符:

Console.WriteLine("\"These two semi colons are removed when i am printed\"");
Run Code Online (Sandbox Code Playgroud)

此外,您引用的字符(")不是分号而是引号.分号是;.


Rom*_*syk 5

只需添加\. 请参阅字符串文字文章

Console.WriteLine("\"These two semi colons are removed when i am printed\"");
Run Code Online (Sandbox Code Playgroud)