I have the following classes:
public class Item
{
}
public class ItemCollection<TItem> : ICollection<TItem> where TItem : Item, new()
{
}
I have two derived classes:
public class Feature : Item
{
}
public class Features : ItemCollection<Feature>
{
}
I have a manager class to manage such collections:
public class ItemCollectionManager<TCollection> where TCollection : ItemCollection<Item>, new()
{
}
I tried to use this class:
public class FeatureManager : ItemCollectionManager<Features>
{
}
but this results in:
"The type Features
must be convertible to ItemCollection<Item>
in order to use it as TCollection in the generic class ItemCollectionManager<TCollection>
".
And as previously mentioned,
Features
is-a ItemCollection<Feature>
and
Feature
is-a Item
.
I do not believe interfaces are the ideal solution to this task but am willing to change if reason is provided.
If anyone could advise on what I'm doing wrong it would be very much appreciated.
Thank you.