Home > .NET > Generics – why all the fuss? Explained.

Generics – why all the fuss? Explained.

I have just never really understood all the fuss about Generics (the upcoming feature in 2.0). Maybe it is because I have never used templates in C++ or done anything meaningful in C++ for that matter! 🙂

At the moment,I derive from the System.Collections.CollectionBase and System.Collections.DictionaryBase abstract classes to easily create strongly typed collections when I need them. This approach is poor for performance due to all the casting required but this is seldom a problem in business applications where bigger bottlenecks can typically be found elsewhere and to-the-metal performance is seldom a concern.

Today I came acrossGenerics In-Depthby J. Ambrose Little -our editor-in-chiefat AspAlliance. Ambrose goes beyond the typical “strongly typed stack” example that we have all seen in the demos and shows constraints, type inference, discusses limitations and evenmakes comparisons to Java’s upcoming generics (1.5). He also provides some advanced code samples to show generics in use. This article is a great read.

What uses do you have for generics? Do you use CollectionBase and DictionaryBase now (presentations on Generics seldom mention them)?

Categories: .NET
  1. http://
    September 10, 2004 at 12:15 pm

    From what I understand, generics will let you have strongly type collections (among other things) without having to explicitly define a new collection class for each type. You just define one for all similar based collections. I think it will shorten coding quite a bit. There are other reasons I’ve heard of (haven’t played around with it all yet unfortunately) but this sounds like one of the biggest advantages for me.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: