CSharp - Generic Types Subclassing

Introduction

A generic class can be subclassed.

The subclass can leave the base class's type parameters open

The following code creates two classes. SpecialSet<T> leaves the type parameter as is.

class Set<T>{
}
class SpecialSet<T> : Set<T> {
}

Or the subclass can close the generic type parameters with a concrete type:

class IntSet : Set<int>  {
}

A subtype can also introduce fresh type arguments:

class Collection<T>                     {
}
class KeyedCollection<T,TKey> : Collection<T> {
}

The following code renamed the generic type.

class Collection<T> {...}
class KeyedCollection<TElement,TKey> : Collection<TElement> {...}