Why is ForEach Iteration over List<T> faster than IList<T>

In this post, I would like to draw your attention to the performance implications when iterating over IList<T> and List<T> . First let us begin by writing some code to run our benchmark tests against. We will execute a simple foreach loop against IList<T> and List<T>. [Benchmark] [ArgumentsSource(nameof(IListCollection))] public void ForEachIList(IList<int> collection) { foreach (var item in collection) { DoSomething(item); } } … Continue reading Why is ForEach Iteration over List<T> faster than IList<T>