Subclassing Generic Types - CSharp Custom Type

CSharp examples for Custom Type:Generics

Introduction

A generic class can be subclassed like a nongeneric class.

The subclass can leave the base class's type parameters open, as in the following example:

class Stack<T>                   {}
class SpecialStack<T> : Stack<T> {}

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

class IntStack : Stack<int>  {}

A subtype can also introduce fresh type arguments:

class List<T>                     {}
class KeyedList<T,TKey> : List<T> {}

Related Tutorials