switch (myTransport) { case Car car: car.Drive(); break; case Plane plane: plane.Fly(); break; default: break; }