Generic名前空間

ジェネリック コレクション インターフェイス (Generic collection interface)

ジェネリックなインターフェイスと、非ジェネリックなそれとの対応
ジェネリック 非ジェネリック
IEnumerable<T> IEnumerable
ICollection<T> ICollection
IList<T> IList
IDictionary<TKey,TValue> IDictionary
IEnumerator<T> IEnumerator
IComparer<T> IComparer
IComparable<T> IComparable
ISet<T>  
インターフェイス - System.Collections.Generic 名前空間 | Microsoft Learn
読み取り専用
インターフェイス 概念
IReadOnlyCollection<T> ReadOnlyCollection<T>
IReadOnlyList<T>  
IReadOnlyDictionary<TKey,TValue>  

IEnumerable<T>

public interface IEnumerable<out T> : IEnumerable
{
    IEnumerator<T> GetEnumerator();
}
IEnumerable<T> インターフェイス (System.Collections.Generic) | Microsoft Learn

このインターフェイスを実装するオブジェクトに対しては、Enumerableクラスを介して標準クエリ演算子を適用できます。

GetEnumerator()

コレクションを反復 (iterate) するための、列挙子 (enumerator) を得られます。これはforeachステートメントで利用されます。

public System.Collections.Generic.IEnumerator<out T> GetEnumerator ();
IEnumerable<T>.GetEnumerator メソッド (System.Collections.Generic) | Microsoft Learn

戻り値のIEnumerator<T>はIDisposableを継承するため、破棄するようにします。

ICollection<T>

ジェネリック コレクションを操作するためのメソッドが定義されます。

public interface ICollection<T> : IEnumerable<T>, IEnumerable
{
    int Count { get; }
    bool IsReadOnly { get; }

    void Add(T item);
    void Clear();
    bool Contains(T item);
    void CopyTo(T[] array, int arrayIndex);
    bool Remove(T item);
}
ICollection<T> インターフェイス (System.Collections.Generic) | Microsoft Learn

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);
}
IList<T> インターフェイス (System.Collections.Generic) | Microsoft Learn

ISet<T>

一意の要素である、ひとそろい (set) を抽象化します。

public interface ISet<T> : ICollection<T>, IEnumerable<T>, IEnumerable
{
    bool Add(T item);
    void ExceptWith(IEnumerable<T> other);
    void IntersectWith(IEnumerable<T> other);
    bool IsProperSubsetOf(IEnumerable<T> other);
    bool IsProperSupersetOf(IEnumerable<T> other);
    bool IsSubsetOf(IEnumerable<T> other);
    bool IsSupersetOf(IEnumerable<T> other);
    bool Overlaps(IEnumerable<T> other);
    bool SetEquals(IEnumerable<T> other);
    void SymmetricExceptWith(IEnumerable<T> other);
    void UnionWith(IEnumerable<T> other);
}
ISet<T> インターフェイス (System.Collections.Generic) | Microsoft Learn

IEnumerator<T>

public interface IEnumerator<out T> : IDisposable, IEnumerator
{
    T Current { get; }
}
IEnumerator<T> インターフェイス (System.Collections.Generic) | Microsoft Learn

IReadOnlyCollection<T>

public interface IReadOnlyCollection<out T> : IEnumerable<T>, IEnumerable
{
    int Count { get; }
}
IReadOnlyCollection<T> インターフェイス (System.Collections.Generic) | Microsoft Learn

IReadOnlyList<T>

public interface IReadOnlyList<out T> : IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
{
    T this[int index] { get; }
}
IReadOnlyList<T> インターフェイス (System.Collections.Generic) | Microsoft Learn

このインターフェイスを実装するCollection<T>クラスを介することで、IList<T>からIReadOnlyList<T>を得られます。

IReadOnlyList<int> items = new Collection<int>(list);

ジェネリック コレクション クラス (Generic collection class)

  概念 キー 重複 ジェネリック 非ジェネリック 実装 (implement)
  値のコレクション × List<T> ArrayList 配列
ダブルリンク リスト × LinkedList<T> なし  
  値のコレクション。重複しない × × HashSet<T>    
キーと値のコレクション × Dictionary<TKey,TValue> Hashtable ハッシュテーブル 注釈
  値で並べ替えられた、値のコレクション。重複しない × × SortedSet<T>    
キーで並べ替えられた、キーと値のコレクション × SortedList<TKey,TValue> ※1 SortedList (並べ替えられた) 配列 注釈
キーで並べ替えられた、キーと値のコレクション × SortedDictionary<TKey,TValue> ※1 なし 二分探索木 (binary search tree) 注釈
  先入れ先出し (FIFO) のコレクション × Queue<T> Queue 循環配列 注釈
後入れ先出し (LIFO) のコレクション × Stack<T> Stack  

※1 SortedList<TKey,TValue>とSortedDictionary<TKey,TValue>は下表のような違いがあります。

比較対象 相違
メモリの使用量 SortedListの方が小さい
並べ替えられていないデータの挿入と除去 SortedDictionaryの方が早い
並べ替えられたデータから一括で設定 SortedListの方が早い
インデックスによるキーと値へのアクセス SortedListは可能。SortedDictionaryは不可能
Remarks - SortedList<TKey,TValue> Class (System.Collections.Generic) | Microsoft Learn

スレッド セーフなコレクション クラス

クラス  
SynchronizedCollection<T>  
SynchronizedKeyedCollection<K,T>  
SynchronizedReadOnlyCollection<T>  

可能ならば、Concurrent名前空間で定義されているクラスを用います。c# - What is the difference between SynchronizedCollection<T> and the other concurrent collections? - Stack Overflow

SynchronizedCollection<T>

内部ではlockで同期されています。SynchronizedCollection.cs

このクラスが含まれるアセンブリSystem.ServiceModelは既定で参照されないため、明示的に参照に追加する必要があります。SynchronizedCollection<T> クラス (System.Collections.Generic) | Microsoft Learn

Microsoft Learnから検索