看看如下代码:
public class Animal
{
public void EatFood(System.Windows.Forms.TextBox myTextBox)
{
myTextBox.Text="Animal EatFood Method";
} }
public class Cow:Animal
{
public void EatFood(System.Windows.Forms.TextBox myTextBox)
{ myTextBox.Text="Cow EatFood Method";
}
}
private void button3_Click(object sender, System.EventArgs e)
{
Cow myCow=new Cow();
Animal myAnimal=myCow;
myAnimal.EatFood(this.textBox3);
}大家说最后是显示什么?是"Cow EatFood Method" 还是"Animal EatFood Method"??
public class Animal
{
public void EatFood(System.Windows.Forms.TextBox myTextBox)
{
myTextBox.Text="Animal EatFood Method";
} }
public class Cow:Animal
{
public void EatFood(System.Windows.Forms.TextBox myTextBox)
{ myTextBox.Text="Cow EatFood Method";
}
}
private void button3_Click(object sender, System.EventArgs e)
{
Cow myCow=new Cow();
Animal myAnimal=myCow;
myAnimal.EatFood(this.textBox3);
}大家说最后是显示什么?是"Cow EatFood Method" 还是"Animal EatFood Method"??
但不规范,我从来不喜欢我的程序编译的时候有任何warning
不过也不一定
abstract也型