c# - Class with generic list of the inherited class type - multiinheritence -


i have asked question in link class generic list of inherited class type

now, in following solution. in situation, how can list (descendents) of tvguid ?

#region parentitem public class baseheaderfooteritem<t>     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 

you can instantiate baseheaderfooteritem class this:

var baseheaderfooteritem = new baseheaderfooteritem<tvguid>(); baseheaderfooteritem.descendants = new list<tvguid> { new tvguid() }; 

so descendats' type list < tvguid>. alternatively can create class, inherits baseheaderfooteritem< tvguid>. have same list< tvguid> property.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -