把\"在逐字字符串使用C# [英] Putting \" in verbatim string with C#
本文介绍了把\"在逐字字符串使用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要打印
a
"b"
c
与vebatim字符串,我提出了有关多线code ++模板的这里。
我试图与逐字字符串如下:
I tried with verbatim string as follows :
using System;
class DoFile {
static void Main(string[] args) {
string templateString = @"
{0}
\\"{1}\\"
{2}
";
Console.WriteLine(templateString, "a", "b", "c");
}
}
不过,我得到这个错误。
But, I got this error.
t.cs(8,11): error CS1525: Unexpected symbol `{'
t.cs(9,0): error CS1010: Newline in constant
t.cs(10,0): error CS1010: Newline in constant
\{1} \
不工作也没有。
什么是错?
推荐答案
试试这个(,而不是逃跑)
Try this ( "" instead of " to escape )
string templateString = @"
{0}
""{1}""
{2}
";
从C#规格:<一href="http://msdn.microsoft.com/en-us/library/Aa691090">http://msdn.microsoft.com/en-us/library/Aa691090
引号转义序列:
quote-escape-sequence: ""
这篇关于把\&QUOT;在逐字字符串使用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文