コード スニペットを検討してください。
IList<String> obj=new List<string>();
IEnumerable<Object> obj1 = obj;
しかし、私が書くICollection<Object> obj2 = obj;
と、コンパイル時エラーが発生します。
System.Collections.Generic.IList<string>
タイプ ' ' を ' ' に暗黙的に変換することはできませんSystem.Collections.Generic.ICollection<object>
。
andと andList<T>
の両方を実装しているため、この動作はなぜですか?IEnumerable<T>
ICollection<T>
IList<T>
public interface IList<T> : ICollection<T>, IEnumerable<T>, IEnumerable
{
T this[int index] { get; set; }
int IndexOf(T item);
void Insert(int index, T item);
void RemoveAt(int index);
}