C# generics syntax for multiple type parameter constraints
Possible Duplicate:
Generic methods and multiple constraints
I need a generic function that has two type constraints, each inheriting from a different base class. I know how to do this with one type:
void foo<T>() where T : BaseClass
However, I don't know how to do this with two types:
void foo<TOne, TTwo>() where TOne : BaseOne // and TTwo : BaseTwo ???
How do you do this? (using .NET 2)
void foo<TOne, TTwo>()
where TOne : BaseOne
where TTwo : BaseTwo
More info here:
http://msdn.microsoft.com/en-us/library/d5x73970.aspx
上一篇: 如何注册和使用相同接口的不同实现?
下一篇: 用于多种类型参数约束的C#泛型语法