C# 获取字符串定义以接受多行?
出于某种原因,下面的语法高亮显示按我所希望的方式工作,但这不是它在VisualStudio中解释代码的方式。当我尝试为一个字符串指定多行时,它不允许我这样做。有没有一种方法可以在不将所有代码合并到一行或为每一行使用+=的情况下完成以下工作C# 获取字符串定义以接受多行?,c#,string,C#,String,出于某种原因,下面的语法高亮显示按我所希望的方式工作,但这不是它在VisualStudio中解释代码的方式。当我尝试为一个字符串指定多行时,它不允许我这样做。有没有一种方法可以在不将所有代码合并到一行或为每一行使用+=的情况下完成以下工作 string HtmlCode = ""; HtmlCode = " <head> <style>
string HtmlCode = "";
HtmlCode =
"
<head>
<style>
*{margin: 0px;padding: 0px;font-family: Microsoft Sans Serif;font-size: 11px;}
</style>
</head>
";
字符串HtmlCode=”“;
HtmlCode=
"
*{边距:0px;填充:0px;字体系列:Microsoft Sans Serif;字体大小:11px;}
";
使用在字符串前面加上@
string HtmlCode = "";
HtmlCode =
@"
<head>
<style>
*{margin: 0px;padding: 0px;font-family: Microsoft Sans Serif;font-size: 11px;}
</style>
</head>
";
字符串HtmlCode=”“;
HtmlCode=
@"
*{边距:0px;填充:0px;字体系列:Microsoft Sans Serif;字体大小:11px;}
";
使用在字符串前面加上@
string HtmlCode = "";
HtmlCode =
@"
<head>
<style>
*{margin: 0px;padding: 0px;font-family: Microsoft Sans Serif;font-size: 11px;}
</style>
</head>
";
字符串HtmlCode=”“;
HtmlCode=
@"
*{边距:0px;填充:0px;字体系列:Microsoft Sans Serif;字体大小:11px;}
";
使用文字字符串:
string HtmlCode = @"
<head>
<style>
*{margin: 0px;padding: 0px;font-family: Microsoft Sans Serif;font-size: 11px;}
</style>
</head>";
string HtmlCode=@”
*{边距:0px;填充:0px;字体系列:Microsoft Sans Serif;字体大小:11px;}
";
使用文字字符串:
string HtmlCode = @"
<head>
<style>
*{margin: 0px;padding: 0px;font-family: Microsoft Sans Serif;font-size: 11px;}
</style>
</head>";
string HtmlCode=@”
*{边距:0px;填充:0px;字体系列:Microsoft Sans Serif;字体大小:11px;}
";
在字符串前面加一个“@”
字符串HtmlCode=”“;
HtmlCode=
@"
*{边距:0px;填充:0px;字体系列:Microsoft Sans Serif;字体大小:11px;}
";
在字符串前面加一个“@”
字符串HtmlCode=”“;
HtmlCode=
@"
*{边距:0px;填充:0px;字体系列:Microsoft Sans Serif;字体大小:11px;}
";
噢,哇,@也适用于多行!我还以为这只是为了“\”呢。无论如何,非常感谢,我在Stack-O上一直学到了一些新东西:)哦,哇,这个@也适用于多行!我还以为这只是为了“\”呢。无论如何,非常感谢,我一直在Stack-O上学到一些新东西:)