private static int Static0(BaseClass co) { int s = 0; s += ((Iface1)co).Method1a(); s += (co as Iface1).Method1a(); s += ((Iface2)co).Method2a(); s += (co as Iface2).Method2a(); if (co is Iface3) { s += ((Iface3)co).Method3a(); s += (co as Iface3).Method3a(); } else { try { return ((Iface3)co).Method3a() + (co as Iface3).Method3a(); } catch { s += 1000; } } return s; }
private static int Main() { CoClass co = new CoClass(); if (Static1(co) != 444) { Console.WriteLine("Test 1 failed."); return 101; } if (Static2(co) != 444) { Console.WriteLine("Test 2 failed."); return 102; } if (Static3(co) != 444) { Console.WriteLine("Test 3 failed."); return 103; } BaseClass bs = new BaseClass(); if (Static4(bs) != 2044) { Console.WriteLine("Test 4 failed."); return 104; } if (Static5(bs) != 2044) { Console.WriteLine("Test 5 failed."); return 105; } Console.WriteLine("Passed"); return 100; }