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:
p开发者_开发问答ublic class NetworkingCollection<T> : List<T>
where T : IStoreItem or ILoadItem
{
}
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.
精彩评论