Partager via


System.Collections.Generics

I have been starting to use CLR Generics. Absolutely useful for day to day software design and implementation.

using Generics = System.Collections.Generics;
...
private Generics.IList<int> myList = new Generics.List<int>(capacity);

myList.Add(100);
myList.Add(201);
myList.Add(303);

The sample above might look very much like ArrayList and it's being use all over the place. If you compare ArrayList to Generic List, generic list is much much better because no casting to object and back (or boxing/unboxing) which will result in better performance.

This is not all the benefits, you can use other generic class like a Queue or a stack (pretty much reminds me of STL) and of course you can write your own generic class or inherit from existing ones.

Comments

  • Anonymous
    January 31, 2004
    Just curious, but who is "I"?