Jar*_*nal 21 c# asp.net-mvc compiler-errors
当我尝试为htmlstring类型的变量赋值时,我收到错误"无法将类型'字符串'隐式转换为'System.Web.HtmlString',该值正在从xml文件中读取(下面的代码片段)
convert方法没有从string到htmlstring的内置转换.有一个方法ToHtmlString但不确定如何在这种情况下使用它,因为它不适用于字符串对象.请你的建议.
public class Xclass
{
public HtmlString content { get; set; }
public string id { get; set; }
}
Xclass x = (from c in xdoc.Descendants("div") select new Xclass()
{
content = c.Value, //c.value is the html content of div, content is a property of type HtmlString
id = c.id
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28515 次 |
| 最近记录: |