Should we use arrays or Generic Collections?

by EvanJPalmer


I tend to not use arrays when writing new code.

I recently noticed arrays in another developer’s code and started thinking more about them and why they are absent from my box of tools. In short, I think they there are better structures for handling collections in C# and if we use them, instead of the array, we’re giving the consumer of the service (or class or method or whatever) a small present in the extra features that better structures have. And you get this for free – as far as I know there’s no performance hit.

I actually would go so far as to say that as of C# 2.0 (when generics were introduced) arrays have become obsolete. That is to say, I can’t think of a time when I would choose to use an array over a generic list.

Eric Gunnerson wrote a great post on small in, big out, that resonates with my thinking about arrays.


Just found this too: