static void Main(string[] args) { // create a new instance of the Calculator class DerivedCalc calc = new DerivedCalc(); // subscribe to the event in the calaculator class calc.CalculationPerformedEvent += HandleEvent; // perform a calculation calc.CalculateProduct(20, 72); // wait for input before exiting Console.WriteLine("Press enter to finish"); Console.ReadLine(); }
static void Main(string[] args) { // create an instance of the derived class DerivedCalc calc = new DerivedCalc(); // upcast to the base type BaseCalc bCalc = calc; // upcast the dervied type to the interface type ICalculator iCalc = calc; // call the method defined by the interface and // print out the results int result = iCalc.CalculateSum(10, 10); Console.WriteLine("Result: {0}", result); // wait for input before exiting Console.WriteLine("Press enter to finish"); Console.ReadLine(); }