C# generics syntax for multiple type parameter constraints

C#Generics

C# Problem Overview


> 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)

C# Solutions


Solution 1 - C#

void foo<TOne, TTwo>() 
   where TOne : BaseOne
   where TTwo : BaseTwo

More info here:
http://msdn.microsoft.com/en-us/library/d5x73970.aspx

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJon BView Question on Stackoverflow
Solution 1 - C#Joel MartinezView Answer on Stackoverflow