views:

66

answers:

2

Imagine the following method

public void SomeMethod<T>(T param)
    where T: List<T2>
{
}

It doesn'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?

+9  A: 

In order to do this, you need to specify an additional generic parameter

public void SomeMethod<T1,T2>(T1 param)
  where T1 : List<T2>
{
}
JaredPar
+3  A: 

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) 
{
}
James
Good point!!!!!!
Jader Dias