foreach가 가능하다.
// 1. foreach
foreach (var x in collection)
{
// ...
}
// 2. 컴파일 된 foreach
var enumerator = collection.GetEnumerator();
while (enumerator.MoveNext())
{
var x = enumerator.Current; // ← 여기서 복사됨
}
// 3. 불가능 코드 (당연한)
var list = new List<int>();
list.Add(1);
list.Add(2);
foreach(var i in list)
{
i += 1; // 컴파일 에러
}
LINQ 가능하다.
Stack<T> , Queue<T>는 IReadonlyCollection<T>를 구현한다.
ICollection 과 ICollection<T>는 서로 다르다. IEnumerable과 IEnumerable<T>는 계승 관계다.
ICollection<T> seems like ICollection, but it’s actually a very different abstraction. We found that ICollection was not very useful. At the same time, we did not have an abstraction that represented an read/write non-indexed collection. ICollection<T> is such abstraction and you could say that ICollection does not have an exact corresponding peer in the generic world; IEnumerable<T> is the closest.
IEnumerable

Implement
public class List<T> :
System.Collections.Generic.ICollection<T>,
System.Collections.Generic.IEnumerable<T>,
System.Collections.Generic.IList<T>,
System.Collections.Generic.IReadOnlyCollection<T>,
System.Collections.Generic.IReadOnlyList<T>,
System.Collections.IList
public class Queue<T> :
System.Collections.Generic.IEnumerable<T>,
System.Collections.Generic.IReadOnlyCollection<T>,
System.Collections.ICollection
ICollection<T>를 구현해야 Count, Clear(), Contains(T), Add(T), Remove(T)를 사용 할 수 있다.

5개 모두 Count는 사용 가능하다.