ジェネリックインターフェイスの問題を解決する方法がわかりません。
ジェネリックインターフェイスは、オブジェクトのファクトリを表します。
interface IFactory<T>
{
// get created object
T Get();
}
インターフェイスは、一般的なファクトリを指定するコンピュータ(コンピュータクラス)のファクトリを表します。
interface IComputerFactory<T> : IFactory<T> where T : Computer
{
// get created computer
new Computer Get();
}
ジェネリックインターフェイスは、クローン可能なオブジェクトの特別なファクトリを表します(インターフェイスSystem.ICloneableを実装します)。
interface ISpecialFactory<T> where T : ICloneable, IFactory<T>
{
// get created object
T Get();
}
クラスは、コンピューター(コンピュータークラス)およびクローン可能オブジェクトのファクトリを表します。
class MyFactory<T> : IComputerFactory<Computer>, ISpecialFactory<T>
{
}
MyFactoryクラスでコンパイラエラーメッセージが表示されます。
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'.