假设我有一些通用的interface IMyInterface<TParameter1, TParameter2>
。C#通用参数
现在,如果我正在写另一个类,一般在它的参数T
:
CustomClass<T> where T : IMyInterface
应该如何进行?
(当前代码不能编译,因为IMyInterface
取决于TParameter, TParameter2
)。
我认为它应该像做:
CustomClass<T, TParameter1, TParameter2> where T: IMyInterface<TParameter1,
TParameter2>
,但我可能是错的,你能指点我好吗?
你的假设是正确的。 – 2011-02-02 21:01:10