I have the following code
interface IEncryption{}
class EncryptionA : IEncryption {}
class EncryptionHandler<T> where T: IEncryption{}
class EncryptionMenu
{
public EncryptionMenu(EncryptionHandler<IEncryption> encryption){}
}
void main()
{
EncryptionMenu encryptionMenu = new EncryptionMenu(new EncryptionHandler<EncryptionA>()); // Error
}
I get
"Argument type 'EncryptionHandler< EncryptionA>' is not assignable to parameter type 'EncryptionHandler< IEncryption>'"
and I cant understand why it cant convert it even though EncryptionA implements IEncryption and is supposed to cast it. I tried to make the EncryptionMenu generic too but it makes the same error bubble upwards and complicates the code.