Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • 7
    Performance issues aside, I prefer usage of Arrays over Lists for their fixed size (in cases where changing the number of items is not required, of course). When reading existing code, I find it helpful to quickly know that an item is forced to have fixed size, rather than having to inspect the code further down in the function. Commented Mar 30, 2014 at 16:59
  • 7
    T[] vs. List<T> can make a big performance difference. I just optimized an extremely (nested) loop intensive application to move from lists to arrays on .NET 4.0. I was expecting maybe 5% to 10% improvement but got over 40% speedup! No other changes than moving directly from list to array. All enumerations were done with foreach statements. Based on Marc Gravell's answer, it looks like foreach with List<T> is particularly bad. Commented Dec 7, 2015 at 18:48