Reputation: 1043
I have following interfaces defined
interface IStoreItem
{
}
interface ILoadItem
{
}
Now I would like to implement a collection which can handle items of these interafeces but usually a class which realises IStoreItem will not realise ILoadItem. So is there some way I can define a constrain like this:
public class NetworkingCollection<T> : List<T>
where T : IStoreItem or ILoadItem
{
}
Upvotes: 0
Views: 62
Reputation: 499382
This is not supported.
You will need a different class for each interface you want to constrain to.
Alternatively, if you inherit IStoreItem
and ILoadItem
from a common interface (say IGenericItem
), you could constrain to the parent interface.
Upvotes: 5