I have a class Customer (with typical customer properties) and I need to pass around, and databind, a ‘chunk’ of Customer instances. Currently I’m using an array of Customer, but I’ve also used Collection of T (and List of T before I knew about Collection of T). I’d like the thinnest way to pass this chunk around using C# and .NET 3.5.
Currently, the array of Customer is working just fine for me. It data binds well and seems to be as lightweight as it gets. I don’t need the stuff List of T offers and Collection of T still seems like overkill. The array does require that I know ahead of time how many Customers I’m adding to the chunk, but I always know that in advance (given rows in a page, for example).
Am I missing something fundamental or is the array of Customer OK? Is there a tradeoff I’m missing?
Also, I’m assuming that Collection of T makes the old loosely-typed ArrayList obsolete. Am I right there?
No one has mentioned the Framework Guidelines advice: Don’t use
List<T>in public API’s:Also, if your goal is two-way Databinding, have a look at
BindingList<T>(with the caveat that it is not sortable ‘out of the box’!)