I do not know how to solve the problem with common interfaces.
A common interface represents a factory for objects:
interface IFactory<T> {
The interface represents a factory for computers (a class of computers) that have the general form of a factory:
interface IComputerFactory<T> : IFactory<T> where T : Computer { // get created computer new Computer Get(); }
The common interface is a special factory for objects that are cloned (implements the System.ICloneable interface):
interface ISpecialFactory<T> where T : ICloneable, IFactory<T> { // get created object T Get(); }
The class represents a factory for computers (computer class) and cloned objects:
class MyFactory<T> : IComputerFactory<Computer>, ISpecialFactory<T> { }
I get compiler error messages in the MyFactory class:
The type 'T' cannot be used as type parameter 'T' in the generic type or method 'exer.ISpecialFactory<T>'. There is no boxing conversion or type parameter conversion from 'T' to 'exer.IFactory<T>'. The type 'T' cannot be used as type parameter 'T' in the generic type or method 'exer.ISpecialFactory<T>'. There is no boxing conversion or type parameter conversion from 'T' to 'System.ICloneable'.
source share