Scott said:
Do you have a need for strongly-type collections of things?
If so, generics are for you.
Sure, but generics are a lot more than that. The most visible example
of the use of generics in C# are the generic collections, but that's
just one example of how one might use generics.
A very simple answer, for someone that is already familiar with C++
templates, is that generics address a similar need. So where you'd use
a template in C++, you can use generics in C# (generally speaking).
And if you're not already familiar with C++ templates, the reason you'd
use templates or generics is to implement code that can be written in a
generic way (hence the name), not specific to the type that will
actually be used in the concrete use of the code. Then you can reuse
that code without creating new versions of it for each concrete type for
which it's going to be used.
In addition to that reuse advantage, generics also have the advantage
that for reference types the same compiled code is used for all uses of
the generic type (as opposed to doing "copy, paste, search and replace"
which produces a whole new instance of the compiled code for each use).
It's hard to sum up every way in which generics are useful in a single
post, but hopefully the above does some justice to the question. I
would definitely agree that the next step for anyone considering the
question is to read the MSDN documentation on the topic.
Pete