C# Language IEnumerable IEnumerable

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

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;
}


Got any C# Language Question?