public static void CarExploded(object sender, EventArgs e) { if (sender is Car c) { CommonCar.CarEventArgs args = (CommonCar.CarEventArgs)e; Console.WriteLine("CarExploded {0}: {1}", c.Name, args.msg); } }
public static void CarAboutToBlow(object sender, EventArgs e) { // Just to be safe, perform a // runtime check before casting. if (sender is Car c) { CommonCar.CarEventArgs args = (CommonCar.CarEventArgs)e; Console.WriteLine("CarAboutToBlow - {0}: {1}", c.Name, args.msg); } }