如何为这些数据对象定义C#类模型



如何定义具有以下代码将编译并有效的属性的类?

AtomEntry newPost = new AtomEntry();
newPost.Title.Text = "Marriage!";
newPost.Content = new AtomContent();
newPost.Content.Content = "<div xmlns='http://www.w3.org/1999/xhtml'>" +
"<p>Mr. Darcy has <em>proposed marriage</em> to me!</p>" +
"<p>He is the last man on earth I would ever desire to marry.</p>" +
"<p>Whatever shall I do?</p>" +
"</div>";
newPost.Content.Type = "xhtml";

这应该做到:

public class AtomEntry 
{ 
public AtomContent Content { get; set; } 
public Title Title { get; set; } 
}
public class AtomContent 
{ 
public string Content { get; set; } 
public string Type { get; set; } 
}
public class Title 
{ 
public string Text { get; set; } 
}

最新更新