...

/

Constraining the Type Parameters

Constraining the Type Parameters

Understand possible constraints that can be applied to type parameters.

Introduction

A generic can take any type parameter we provide. Sometimes, though, we may want to add some constraints.

Consider a set of classes: Vehicle (abstract base class), Car, Truck (both inherit from Vehicle), and the Garage class to hold our vehicles. Because there are two ...

Access this course and 1400+ top-rated courses and projects.