类继承/覆盖

时间:2016-01-05 18:15:06

标签: c# asp.net-mvc class inheritance override

我有一个普通班。 我想创建另一个类,但需要更少(或更多)特定信息。

所以我从一个班级转换到另一个班级。

如何构建动态继承" OtherClass"?

创建新课程时如何覆盖?

public class NewClass: Atom
{
 ...
}
public class OtherNewClass
    {
        // Elements

        [XmlElement(ElementName = "id")]
        public string id { get; set; }
        [XmlElement(ElementName = "name")]
        public string name { get; set; }
        [XmlElement(ElementName = "NewNew")]
        public string newnew { get; set; }
}

我的代码:

public class Atom
{
    [XmlType(TypeName = "feed", Namespace = "http://www.w3.org/2005/Atom")]
    public class Feed
    {
        [XmlElement(ElementName = "title")]
        public string Title { get; set; }

        [XmlElement(ElementName = "updated")]
        public DateTime? Updated { get; set; }

        [XmlElement(ElementName = "id")]
        public string Id { get; set; }

        [XmlElement(ElementName = "link")]
        public Link Link { get; set; }

        [XmlElement(ElementName = "entry")]
        public List<Entry> Entries { get; set; }

        public Feed()
        {
            Entries = new List<Entry>();
        }
    }

    public class Entry : OtherClass
    {
        [XmlElement(ElementName = "title")]
        public string Title { get; set; }

        [XmlElement(ElementName = "updated")]
        public DateTime? Updated { get; set; }

        [XmlElement(ElementName = "id")]
        public string Id { get; set; }

        [XmlElement(ElementName = "link")]
        public List<Link> Link { get; set; }

        [XmlElement(ElementName = "category")]
        public Category Category { get; set; }

        [XmlElement(ElementName = "author")]
        public Author Author { get; set; }

        [XmlElement(ElementName = "content")]
        public string Content { get; set; }           [

    }

    [XmlType(TypeName="otherclass", Namespace ="spec/1.0/")]
    public class OtherClass
    {
        // Elements

        [XmlElement(ElementName = "id")]
        public string id { get; set; }
        [XmlElement(ElementName = "name")]
        public string name { get; set; }
        [XmlElement(ElementName = "code")]
        public string code { get; set; }
}

你可以给我一个提示。

0 个答案:

没有答案