在c#中使用此字符串值的最佳方法是什么?

Kur*_*rru 0 html c# string

什么是使下面的HTML文本阻止c#中的硬编码字符串对象的最佳方法?我需要它进行测试不能使用@运算符,因为它只是停在第一个".任何想法?

================================================== ==

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML>

<HEAD>

  <META http-equiv="Content-Type" content="text/html; charset=utf-8">

  <TITLE>Example Web Page</TITLE>

</HEAD> 

<body>  

<p>You have reached this web page by typing &quot;example.com&quot;,

&quot;example.net&quot;,&quot;example.org&quot

  or &quot;example.edu&quot; into your web browser.</p>

<p>These domain names are reserved for use in documentation and are not available 

  for registration. See <a href="http://www.rfc-editor.org/rfc/rfc2606.txt">RFC 

  2606</a>, Section 3.</p>

</BODY>

</HTML>
Run Code Online (Sandbox Code Playgroud)

Dav*_*son 6

你可以使用@但你必须逃避任何"as""(双)

据我所知,没有其他办法.

然后是第一行

@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Transitional//EN"">

<HTML>
Run Code Online (Sandbox Code Playgroud)


Jon*_*eet 5

我建议你把它放在一个文本文件中,然后嵌入到程序集中.这样你可以使用语法高亮等编辑它,它不会使你的代码混乱.

用于Assembly.GetManifestResourceStream在执行时再次加载它.如果你这么做,你可能想要编写帮助方法来更容易地做到这一点.