Mega Code Archive

 
Categories / C# Book / 01 Language Basics
 

0181 Subclassing generic type

When subclassing the generic type we can keep the generic type. class Shape<T>{ } class Rectangle<T>:Shape<T>{ } Or we can close the generic type by replacing the generic type with a concrete type. class Shape<T> { } class Rectangle<int> : Shape<int> { } Or we can add more generic parameters. class Shape<T>{ } class Rectangle<T,K>:Shape<T>{ }