假設我有一些通用的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