我试图将此字符串文字分配给字符串变量.
String myString = @"<h1 style=""font-family: Sans-Serif; font-size: 1.2em;
color: #dedede;border-bottom: solid 1px #dedede;"">Issue</h1><br>;"
Run Code Online (Sandbox Code Playgroud)
我收到一条错误说明以下内容:
方法名称预期
我尝试使用正斜杠"/"没有成功.VS ide在font-family下正好抱怨.
String myString = @"<h1 style=/"font-family: Sans-Serif; font-size: 1.2em; color:
#dedede;border-bottom: solid 1px #dedede;/">Issue</h1><br>"
Run Code Online (Sandbox Code Playgroud)
使用它会产生以下错误:
";" 预期
Hab*_*bib 10
这是你的第一个声明没有错,除了你在结尾处缺少一个分号,这标志着声明结束.
String myString = @"<h1 style=""font-family: Sans-Serif; font-size: 1.2em;
color: #dedede;border-bottom: solid 1px #dedede;"">Issue</h1><br>";
///^^^^ here
Run Code Online (Sandbox Code Playgroud)
你不需要使用正斜杠来转义双引号,它是用于转义字符的反斜杠.但由于您使用@ (字母字符串)字符串,因此需要额外的双引号"来逃避现有的双引号.(你在第一个版本中正确地做了)
| 归档时间: |
|
| 查看次数: |
460 次 |
| 最近记录: |