How do I specify multiple generic type constraints on a single method?
I can restrict generics to a specify type using the "Where" clause such as:
public void foo<TTypeA>() where TTypeA : class, A
How do I do this if my function has two generic types?
public void foo<TTypeA, TTypeB>() where TTypeA : class, A && TTypeB : class, B
The above doesn't work. 开发者_StackOverflow What's the correct syntax to add the rule "TTypeB : class, B"
public void foo<TTypeA, TTypeB>() where TTypeA : class, A
where TTypeB : class, B
public void foo<TTypeA, TTypeB>() where TTypeA : class, A where TTypeB : class, B
dang, 20s late. Vote for James Curran, he was first.
Something like this?
public void foo<TTypeA, TTypeB>() where TTypeA : class where TTypeB : class
just replace &&
with another where
精彩评论