Why I can't implicitly convert Generic<T>
to GenericSetted : Generic<T>
?
This driving me insane:
Declaration:
class GenericParam<T>
{ }
class WithGenericParamAndGeneric<G, T>
where G : GenericParam<T>
{ }
Implementation:
class Generic : GenericParam<string>
{ }
class Inherited : WithGenericParamAndGeneric<Generic, string>
{ }
Trouble:
void Assign()
{
WithGenericParamAndGeneric<GenericParam<string>, string> b = new Inherited(); //(!)
}
Error:
Cannot implicitly convert type 'Inherited' to 'WithGenericParamAndGeneric<GenericParam<string>, string>'
I do not know the reasons in which case CLR can't process this case.