[英]How to escape quote inside a double-quote?
I am adding a table with html:我正在添加一个带有 html 的表格:
string _table = @"{
""version"": {""number"": 2},
""type"":""page"",
""title"":""Table"",
""space"":{""key"":""" + postdata.key + @"""},
""body"":{""storage"":{""value"":""<table><tbody><tr><th><p><strong>Project Basic Informations</strong></p></th></tr></tbody></table>"",""representation"":""storage""}}
}";
And I want to style <th>
with colspan="2"
so the header spans two columns.我想用colspan="2"
<th>
样式,以便标题跨越两列。
I tried the following but it doesn't work:我尝试了以下但它不起作用:
""<table> <tbody> <tr> <th colspan=""2""> <p><strong>Project Basic Informations</strong></p> </th>....""
or <th colspan=\\"2\\"
或<th colspan=\\"2\\"
Is there a way to escape the double-quotes and get the <th>
colspan attribute to work?有没有办法转义双引号并使<th>
colspan 属性起作用?
single-quote on HTML attributes also works. HTML 属性上的单引号也有效。 you can write <th colspan='2'>
你可以写<th colspan='2'>
Just put the \\ inside the string:只需将 \\ 放在字符串中:
string table = "\"<table><tbody><tr><th colspan = \"2\"><p><strong> Project Basic Informations</strong></p></th>....\"";
Or you can use the ascii code of the double-qoute:或者你可以使用double-qoute的ascii代码:
char quote = (char)34;
string table = quote + "<table><tbody><tr><th colspan = " + quote + "2" + quote + "><p><strong> Project Basic Informations</strong></p></th>...." + quote;
Or you can use single-quote asMohammdReza Keikavousi said.或者你可以像MohammdReza Keikavousi所说的那样使用单引号。
您可以在任何转义字符之前使用 / 或仅使用单引号,例如:“ I/”m StackOverflow “ else “ Im StackOverflow”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.