Having learned hat:
( 1. ) Generic collections / type-safe / hold value types: Array (ex Net
0.0.), List and Dictionary (ex Net v2.0.).
( 2. ) Non-generic collections / not type-safe / hold object types:
ArrayList and Hashtable (ex Net v1.0).
Assuming ( 1. ) and ( 2. ) are correct:
They are not. Generic types (not just collection types) may (and often
do) use reference types as the type parameters for the type. As well,
non-generic collection types may hold value types that have been boxed;
technically, they are holding a reference type, but from a semantic point
of view, the only valid types in those collection instances are the value
type for the collection.
(You seem to be using the term "object type" to mean what is correctly
called a "reference type". Especially if you are writing a manual for the
language, it is very important that you use the correct terminology. All
types in .NET are "object types", in that they all inherit System.Object)
I have a problem with the terms. Generic from genus is more general than
species. Given that ( 1. ) applies to value types, cannot contain all
kinds of types, why the use of "generic", that seems contradictory to me.
Generic collections can contain members of _any_ type. Further, as Jason
has explained, the type itself is not specific to any particular type, and
thus is general-purpose, or "generic". Non-generic collection types may
use System.Object as their member type (e.g. ArrayList), or they may use
some more-derived type (e.g. a custom type with strongly typed input and
output members). But they are always special-purpose, in that they can't
be strongly typed with anything other than a single specific type.
Finally, from Jason's reply, a minor clarification:
[...]
I believe the compiler generates the specialised code required
for each data type - from your generic description.
For each use of a generic type with a specific type parameter, the
compiler will generate a specialized type. This will include strongly
typed static members. And for value types as the type parameter, a new
copy of all the code is required for each use. But for reference types,
since type checking can be done at compile time (with explicit casts as
needed by the programmer to satisfy the compile-time rules), all of the
reference-type-based generics can share the same code.
In that respect, while .NET generics is similar to C++ templates, it can
be and often is significantly more efficient in terms of code generation
than C++ templates.
Pete