还是同类问题,帮忙看下吧,谢谢了!
using System;
public class Parent
{
string parentString;
public Parent()
{
Console.WriteLine("Parent Constructor.");
}
public Parent(string myString)
{
parentString = myString;
Console.WriteLine(parentString);
}
public void print()
{
Console.WriteLine("I'm a Parent Class.");
}
}
public class Child : Parent
{
public Child() : base("From Derived")
{
Console.WriteLine("Child Constructor.");
}
public void print()
{
base.print();
Console.WriteLine("I'm a Child Class.");
}
public static void Main()
{
Child child = new Child();
child.print();
((Parent)child).print();
}
}
错误提示:basetalk.cs(26,14): warning CS0108: The keyword new is required on
'Child.print()' because it hides inherited member 'Parent.pri
basetalk.cs(14,14): (Location of symbol related to previous warning)