Cannot implicitly convert type 'string' to 'System.Web.HtmlString' in C#?

Я получаю ошибку "Cannot implicitly convert type 'string' to 'System.Web.HtmlString' when I attempt to assign a value to a variable of type htmlstring, the value is being read from an xml file (code snippet below)

Метод convert не имеет встроенного преобразования из строки в 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
});
21
задан tereško 4 August 2012 в 17:41
поделиться