I have the following classes and method:
public class MyGenericClass<T>
where T : class
{
}
public class MyClass
{
public TGen MyMethod<TGen>(TGen myGenClass)
where TGen : MyGenericClass<T>
where T : class
{
return myGenClass;
}
}
However, this gives an error because it cannot resolve the symbol T in MyMethod. I would prefer to not have to have MyMethod<TGen, T> since it seems a bit redundant to me. Is this possible?
If you want to be able to use any
MyGenericClassimplementation for yourTGentype, then you will need to create a base class of theMyGenericClassimplementation to use (of course, this limits what functionality you will get for yourTGeninstance.