【问题标题】:How to define a C# class model for these dataobjects [closed]如何为这些数据对象定义 C# 类模型 [关闭]
【发布时间】:2020-07-08 22:15:18
【问题描述】:

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

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# 类吗?

标签: c# class model datamodel


【解决方案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; } 
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-21
    • 2021-03-23
    • 1970-01-01
    • 2021-09-20
    • 1970-01-01
    • 1970-01-01
    • 2014-12-21
    • 1970-01-01
    相关资源
    最近更新 更多