私は2つのインターフェースを持っています。私はリストと配列のためにそれらを使用したい。2つのジェネリックと無限
public interface IBook<T>
{
string Name { get; set; }
T Authors { get; set; }
int PagesCount { get; set; }
}
public interface IAuthor<T>
{
string Name { get; set; }
T Books { get; set; }
}
class Author<T> : IAuthor<IBook<T>[]>
where T : IAuthor<IBook<T>[]>
{
public string Name { get; set; }
public IBook<T>[] Books { get; set; }
}
class Book<T> : IBook<IAuthor<T>[]>
where T : IBook<IAuthor<T>[]>
{
public string Name { get; set; }
public IAuthor<T>[] Authors { get; set; }
public int PagesCount { get; set; }
public static void Main(string[] args)
{
Author<IBook<IAuthor<...>[]>[]> a = new Author<>();
}
}
mainのようにオブジェクトを作成する方法はありますか。コンパイラは、インターフェイスとクラスの記述にエラーはないと言います。私を助けてください。
をそれらをオブジェクトとして扱うか、リストを作成するか? –
ここでジェネリックを使用したい理由は何ですか?また、 'Books 'と' Authors'はなぜT []の代わりに 'T'ですか?結局、それらの名前は複数形です。 –
IEnumerableを実装しているIAookOolCollectionを作成し、使用します。IAuthor –
MistyK