Storing an object that implements multiple interfaces and derives from a certain base (.net)
- 阅读更多 关于 Storing an object that implements multiple interfaces and derives from a certain base (.net)
问题 In .net, it's possible to use generics so that a function can accept arguments which support one or more interfaces and derive from a base type, even if there does not exist any single type from which all valid argument types derive. For example, one could say: Sub Foo(Of T As {IInterface1, IInterface2, SomeBaseType})(Param as T) and be allowed to pass any derivative of SomeBaseType which implements both IInterface1 and IInterface2. This will work even if SomeBaseType does not support