What is the IEnumerable interface?

Answer

IEnumerable<T> is the fundamental interface for sequences in .NET — it defines a single method: IEnumerator<T> GetEnumerator(). Any type implementing IEnumerable<T> can be iterated with foreach and used with LINQ. It represents a read-only, forward-only sequence — you can iterate it but not index into it directly, modify it, or know its count without enumerating. ICollection<T> adds Count and Add/Remove. IList<T> adds index access. Parameter typing rule: accept the most general type your method needs — if you only iterate, accept IEnumerable<T>. Arrays, List<T>, HashSet<T>, LINQ queries, and generator methods (yield return) all implement IEnumerable<T>. Generator methods: yield return creates a lazy state machine implementing IEnumerable<T>.