Justin said:
you can define two class with same name but having different generic
parameters in one assembly. As below:
class Gen<T>
{
}
class Gen<T1,T2>
{
}
Assuming you're talking about C# 2.0 (Whidbey), are you sure that you
can do this? I haven't played around with Whidbey much, but my reading
of the draft spec indicates that this is not supported (from Section 20.1):
=================================================================
Generic types may not be “overloaded”, that is the identifier of a
generic type must be uniquely named within a scope in the same way as
ordinary types.
class C {}
class C<V> {} // Error, C defined twice
class C<U,V> {} // Error, C defined twice
However, the type lookup rules used during unqualified type name lookup
(§20.9.3) and member access (§20.9.4) do take the number of generic
parameters into account.
=================================================================
The exceptions listed above allow generic types in, for example,
different namespaces to have the same 'simple name' with differing type
parameters. But, since they are in different namespaces they are really
completely unrelated (other than they they happen to share the same
simple name).
I think this is one of the reasons that you find the generic classes in
..NET 2.0 in separate namespaces from their non-generic counterparts.
On the other hand, I don't see the reason why they couldn't allow type
parameters to overload class names, but I'm not a language design
expert, so there's probably a very good reason.