For some reason, the syntax highlighting below is working how I'd like it to, but this is not how it interprets the code in Visual Studio. When I try to assign multiple lines to a string, it won't let me. Is there a way i can make the following work without combining all o开发者_JAVA百科f my code into one line or using a += for each new line?
string HtmlCode = "";
HtmlCode =
"
<head>
<style>
*{margin: 0px;padding: 0px;font-family: Microsoft Sans Serif;font-size: 11px;}
</style>
</head>
";
Use verbatim string by prefixing your string with @
string HtmlCode = "";
HtmlCode =
@"
<head>
<style>
*{margin: 0px;padding: 0px;font-family: Microsoft Sans Serif;font-size: 11px;}
</style>
</head>
";
Use literal strings:
string HtmlCode = @"
<head>
<style>
*{margin: 0px;padding: 0px;font-family: Microsoft Sans Serif;font-size: 11px;}
</style>
</head>";
Prefix the string with an "@"
string HtmlCode = "";
HtmlCode =
@"
<head>
<style>
*{margin: 0px;padding: 0px;font-family: Microsoft Sans Serif;font-size: 11px;}
</style>
</head>
";
精彩评论