You can overload generic definitions providing different signatures for the type parameter, similar to what happens in methods overloads. The following code provides an example:
It is worth mentioning that providing a nongeneric version of your class is not necessary. In this way you can provide different implementations for your generic types. Now consider the following overloading attempt:
This code is not compiled because although in the second definition some constraints are defined, the type implementation is considered by the compiler with the same identical signature. Similarly you can provide overloaded methods using techniques learned in Chapter 7, “Class Fundamentals,” but against generic methods as demonstrated in the following code:
Overloading provides great granularity over Generics implementation, and you will often see examples in built-in generic collections.
18.118.147.160