public static void Main() { Class1 obj1 = new Class1(); CheckReturnedInt(obj1.F1("obj1"), 1); CheckReturnedString(obj1.F2("obj1"), "String returned from Class1.F2:obj1"); CheckReturnedString(obj1.NonVirtualFunc(11), "String returned from Class1.NonVirtualFunc:11"); Console.WriteLine(""); Class2 obj2 = new Class2(); CheckReturnedInt(obj2.F1("obj2"), 2); CheckReturnedString(obj2.F2("obj2"), "String returned from Class2.F2:obj2"); CheckReturnedString(obj2.NonVirtualFunc(15), "String returned from Class2.NonVirtualFunc:30"); Console.WriteLine(""); I1 itf; itf = obj1; CheckReturnedInt(itf.F1("itf is now obj1"), 1); CheckReturnedString(itf.F2("itf is now obj1"), "String returned from Class1.F2:itf is now obj1"); Console.WriteLine(""); itf = obj2; CheckReturnedInt(itf.F1("itf is now obj2"), 2); CheckReturnedString(itf.F2("itf is now obj2"), "String returned from Class2.F2:itf is now obj2"); Console.WriteLine(""); if (failed) { System.Environment.ExitCode = 1; } else { System.Environment.ExitCode = 0; } }
public static void Main() { Class1 obj1=new Class1(); CheckReturnedInt(obj1.F1("obj1"), 1); CheckReturnedString(obj1.F2("obj1"), "String returned from Class1.F2:obj1"); CheckReturnedString(obj1.NonVirtualFunc(11), "String returned from Class1.NonVirtualFunc:11"); Console.WriteLine(""); Class2 obj2=new Class2(); CheckReturnedInt(obj2.F1("obj2"), 2); CheckReturnedString(obj2.F2("obj2"), "String returned from Class2.F2:obj2"); CheckReturnedString(obj2.NonVirtualFunc(15), "String returned from Class2.NonVirtualFunc:30"); Console.WriteLine(""); I1 itf; itf = obj1; CheckReturnedInt(itf.F1("itf is now obj1"), 1); CheckReturnedString(itf.F2("itf is now obj1"), "String returned from Class1.F2:itf is now obj1"); Console.WriteLine(""); itf = obj2; CheckReturnedInt(itf.F1("itf is now obj2"), 2); CheckReturnedString(itf.F2("itf is now obj2"), "String returned from Class2.F2:itf is now obj2"); Console.WriteLine(""); if (failed) { System.Environment.ExitCode = 1; } else { System.Environment.ExitCode = 0; } }