Wednesday, April 23, 2008

Arrays are so Yesterday (or at least pre .net 2.0)

As I work in Visual Basic for .Net framework 2.0 (or later), I find that I never use arrays any more. Instead, I use generics, i.e., List(of T) where T is a type.

For me, the convenience derives from two basic features:
1) Not having to know in advance the the maximum number of entries
2) Ability to easily check if the item is already in the list via the contains method

I've had developers ask me, "What do you use generics for anyway?". This is a great example of where generics can help make routine programming much easier.

Hope it helps.

Joe Kunk
Okemos, MI

No comments: