c# - Class with generic list of the inherited class type -
i have 3 class:
some of theme have list called descendents of type.
i have generic class in baseheaderfooteritem class. , insery , type of list it.
is there option ?
#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
if want use generics, use generics:
#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
Comments
Post a Comment