Imagine the following method
public void SomeMethod<T>(T param)
where T: List<T2>
{
}
It doe开发者_StackOverflowsn't work:
Error 16 The type or namespace name 'T2' could not be found (are you missing a using directive or an assembly reference?)
How do I achieve the what I clearly intended to do?
In order to do this, you need to specify an additional generic parameter
public void SomeMethod<T1,T2>(T1 param)
where T1 : List<T2>
{
}
As a side answer to the accepted solution, since T is explicitly related to T2, why have T at all?
public void SomeMethod<T2>(List<T2> listParam)
{
}
精彩评论