public static int Main() { Derived1 d1 = new Derived1(); Derived1 x = d1.Method(); Derived2 d2 = new Derived2(); Derived2 y = d2.Method(); return 0; }
public static int Main() { Derived1 d1 = new Derived1(); Derived1 x = d1.Method(); Console.WriteLine(x.GetType()); // outputs Derived1 Derived2 d2 = new Derived2(); Derived2 y = d2.Method(); Console.WriteLine(y.GetType()); // outputs Derived2 }
public static void Main() { Derived1 d1 = new Derived1(); Derived2 d2 = new Derived2(); Base b2 = d2; var sb = new StringBuilder(); sb.AppendLine("d1.Method() = " + d1.Method()); sb.AppendLine("d1.Property = " + d1.Property); sb.AppendLine("d2.Method() = " + d2.Method()); sb.AppendLine("d2.Property = " + d2.Property); sb.AppendLine("b2.Method() = " + b2.Method()); sb.AppendLine("b2.Property = " + b2.Property); Console.WriteLine(sb.ToString()); }