Visual C# verbatim string syntax problem
I am trying to create a string literal in visual C sharp. i don't know why VS is throwing errors about the html test i have inserted the @ "" should allow multi line and be literal from what i have read, w开发者_如何学Pythonhat am i doing wrong?
string test = @"
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
body{font-family:helvetica;}
body{font-size:10px;}
table{ border-collapse:collapse; }
table{border:2px solid black; }
table{font-family:helvetica;}
table{font-size:17px;}
td{border:1px solid #D2B9D3;}
td{font-family:helvetica;}
td{font-size:18px;}
th{border:1px solid black;}
.style4 {font-size: 36px}
</style>
</head>
";
You have to replace " to "" in your html text and it will be fine
EDIT: I just read further on and yes it seems that "" is the correct route since it's a verbatim string.
Actually ""
is a VB.NET thing, in C# you will want \"
to escape the quotes.
Here are some others, for your reference.
http://blogs.msdn.com/b/csharpfaq/archive/2004/03/12/what-character-escape-sequences-are-available.aspx
I found that using ' in place of " also works for your specific situation.
@"<html xmlns='http://www.w3.org/1999/xhtml'>"
精彩评论