static void Main(string[] args) { FlyingCar car = new FlyingCar(); car.Run(); car.Fly(); IRunnable runnable = car as IRunnable; runnable.Run(); IFlyable flyable = car as IFlyable; flyable.Fly(); }
static void Main(string[] args) { FlyingCar car = new FlyingCar(); car.Run(); car.Fly(); car.Company = "현대"; IRunnable runnable = car as IRunnable; //형변환, 형변환 안되면 null값 들어감 runnable.Run(); IFlyable flyable = car as IFlyable; flyable.Fly(); }