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

问题描述 投票:0回答:1
如何定义具有以下代码可编译且有效的属性的类?

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";

c# class model datamodel
1个回答
1
投票
这应该做:

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; } }

© www.soinside.com 2019 - 2024. All rights reserved.