254
可能重复:
Generic methods and multiple constraintsC#泛型语法用于多个类型参数约束
我需要具有两个类型约束的通用函数,每次从一个不同的基类继承。我知道如何用一种类型做到这一点:
void foo<T>() where T : BaseClass
不过,我不知道如何使用两种类型的做到这一点:
void foo<TOne, TTwo>() where TOne : BaseOne // and TTwo : BaseTwo ???
你如何做到这一点? (使用.NET 2)
搜索 “约束的多参数” 如果你不想把它读完了。 – RichardOD 2009-06-08 15:51:25