Skip to main content
 首页 » 编程设计

c#之如何从包含“字符”的文本 block 创建字符串

2024年02月24日34arxive

我有一段 html 代码,其中包含一些表单操作内容,其中 "出现了很多。

有什么方法可以将整个 block 变成一个字符串?

public string methodName() 
{ 
     return @ " text goes here..  blah blah  <p> a bit of html stuff</p> 
<form action="www...." method="post"> 
<input type="hidden" name="cmd"  

我从这里得到了很多愤怒的红色下划线。

请您参考如下方法:

var html = @"<html> 
<body> 
    <span id=""name""> somethnig more</span> 
</body> 
</html>"; 

在字符串前放置@意味着不应解析内容(\n 和其他控制字符不起作用)。也就是字符串可以跨越多行,里面有",只要你写""(只会显示一行)。