Hi There,
I am fairly new to OOP and wondered if you could provide some help on the best solution to the following.
public class GenericClass
{
private List<GenericListItem> _listItems;
}
public class SpecificClass : GenericClass
{
// I'd like to change the listItems specialisation to SpecificListItem (inherits from GenericListItem)
}
How would I be able to achieve the change in specialisation for the collection? Should I be creating a virtual method when adding to the collection and override to specify the correct type (SpecificListItem)? Then cast it to SpecificListItem when accessing it?
Please accept my apologies, this is my first post so it may be vague. If I need to give more information please let me know. Also, I'm sorry for my ignorance in this question!
Many Thanks,
Sam