IEnumerable<T>

Represents a generic collection of objects that can have their IEnumerator<T> accessed.

public interface IEnumerable<out T> : IEnumerable

Remarks

The IEnumerable<T> interface is the base interface for all generic collections that can be enumerated. It provides a way to iterate through the collection and access its elements.

When you implement IEnumerable<T>, you must implement the GetEnumerator method, which returns an enumerator for the collection.

LINQ queries use IEnumerable<T> to iterate over collections. Collections that implement IEnumerable<T> can be used directly in LINQ query syntax or query extension methods.

Members

Name Description
GetEnumerator() Returns an enumerator that iterates through the collection.

Methods

GetEnumerator()

public System.Collections.Generic.IEnumerator<T> GetEnumerator()

Returns

An IEnumerator<T> that can be used to iterate through the collection.