C# 使用继承的类类型的泛型列表初始化
我有三个班: 有些主题列表称为某种类型的后代 我希望在BaseHeaderFooteItem类中有一个泛型类。 和insery以及它的列表类型 有什么选择吗C# 使用继承的类类型的泛型列表初始化,c#,asp.net,oop,polymorphism,C#,Asp.net,Oop,Polymorphism,我有三个班: 有些主题列表称为某种类型的后代 我希望在BaseHeaderFooteItem类中有一个泛型类。 和insery以及它的列表类型 有什么选择吗 #region ParentItem public class BaseHeaderFooterItem { public string Title { get; set; } public string EnTitle { get; set; } public HyperLink Link { get; set;
#region ParentItem
public class BaseHeaderFooterItem
{
public string Title { get; set; }
public string EnTitle { get; set; }
public HyperLink Link { get; set; }
public int Level { get; set; }
}
#endregion
#region HeaderFooter
public class HeaderFooter : BaseHeaderFooterItem
{
public List<Category> Descendants { get; set; }
}
#endregion
#region HeaderFooter
public class Category : BaseHeaderFooterItem
{
public List<Show> Descendants { get; set; }
}
#endregion
#region Header
public class Show : HeaderFooter
{
public string ImagePath { get; set; }
public string MobileLink { get; set; }
public string MobileLinkTarget { get; set; }
}
#endregion
#region TvGuid
public class TvGuid : Show
{
public string Date { get; set; }
public string Time { get; set; }
public int IsActive { get; set; }
public int NoProgram { get; set; }
}
#endregion
#区域父项
公共类BaseHeaderFooteItem
{
公共字符串标题{get;set;}
公共字符串名为{get;set;}
公共超链接{get;set;}
公共整数级别{get;set;}
}
#端区
#区域头门
公共类HeaderFooter:BaseHeaderFooteItem
{
公共列表子体{get;set;}
}
#端区
#区域头门
公共类类别:BaseHeaderFooteItem
{
公共列表子体{get;set;}
}
#端区
#区域标题
公共类节目:HeaderFooter
{
公共字符串ImagePath{get;set;}
公共字符串MobileLink{get;set;}
公共字符串MobileLink目标{get;set;}
}
#端区
#区域TvGuid
公共类TvGuid:Show
{
公共字符串日期{get;set;}
公共字符串时间{get;set;}
public int IsActive{get;set;}
public int NoProgram{get;set;}
}
#端区
如果要使用泛型,可以使用泛型:
#region ParentItem
public class BaseHeaderFooterItem<T>
where T:class
{
public string Title { get; set; }
public string EnTitle { get; set; }
public HyperLink Link { get; set; }
public int Level { get; set; }
public List<T> Descendants { get; set; }
}
#endregion
#region HeaderFooter
public class HeaderFooter : BaseHeaderFooterItem<Category>
{
}
#endregion
#region HeaderFooter
public class Category : BaseHeaderFooterItem<Show>
{
}
#endregion
#region Header
public class Show : HeaderFooter
{
public string ImagePath { get; set; }
public string MobileLink { get; set; }
public string MobileLinkTarget { get; set; }
}
#endregion
#region TvGuid
public class TvGuid : Show
{
public string Date { get; set; }
public string Time { get; set; }
public int IsActive { get; set; }
public int NoProgram { get; set; }
}
#endregion
#区域父项
公共类BaseHeaderFooteItem
T:在哪里上课
{
公共字符串标题{get;set;}
公共字符串名为{get;set;}
公共超链接{get;set;}
公共整数级别{get;set;}
公共列表子体{get;set;}
}
#端区
#区域头门
公共类HeaderFooter:BaseHeaderFooteItem
{
}
#端区
#区域头门
公共类类别:BaseHeaderFooteItem
{
}
#端区
#区域标题
公共类节目:HeaderFooter
{
公共字符串ImagePath{get;set;}
公共字符串MobileLink{get;set;}
公共字符串MobileLink目标{get;set;}
}
#端区
#区域TvGuid
公共类TvGuid:Show
{
公共字符串日期{get;set;}
公共字符串时间{get;set;}
public int IsActive{get;set;}
public int NoProgram{get;set;}
}
#端区
如果我想用list-oh-TvGuid初始化TvGuid类?如果我想用list-oh-TvGuid初始化TvGuid类?