NetMaster
September 19th, 2008, 04:23 AM
Hi,
I've defined a generic class where I tried to access a static method in
'T', but I got the error message: "'T' is a 'type parameter', which is not valid in the given context"
public class MyGenericClass<T>
where T : new()
{
public void MyMethod()
{
string s = T.GetString(); // GetString() is a static method
^
error here
}
}
Is there something missing in the constraints or isn't it possible to access static methods in the type parameter ?
PS: I'm using MVS 2005
I've defined a generic class where I tried to access a static method in
'T', but I got the error message: "'T' is a 'type parameter', which is not valid in the given context"
public class MyGenericClass<T>
where T : new()
{
public void MyMethod()
{
string s = T.GetString(); // GetString() is a static method
^
error here
}
}
Is there something missing in the constraints or isn't it possible to access static methods in the type parameter ?
PS: I'm using MVS 2005