C# Language IEnumerable


In its most basic form, an object that implements IEnumerable represents a series of objects. The objects in question can be iterated using the c# foreach keyword.

In the example below, the object sequenceOfNumbers implements IEnumerable. It represents a series of integers. The foreach loop iterates through each in turn.

int AddNumbers(IEnumerable<int> sequenceOfNumbers) {
    int returnValue = 0;
    foreach(int i in sequenceOfNumbers) {
        returnValue += i;
    return returnValue;