using System;
using System.Collections.Generic;public class Father
{
public void hand()
{
Console.WriteLine("Father.hand");
}
}public class Son : Father
{
public new void hand()
{
Console.WriteLine("Son.hand");
}
static void Main(string[] args)
{
Father son = new Son();
son.hand();
Console.ReadLine();
}
}这个是吧基类中的hand() 隐藏了吧,在Son 类中,,,,,,,运行结果是Father.hand why?
using System.Collections.Generic;public class Father
{
public void hand()
{
Console.WriteLine("Father.hand");
}
}public class Son : Father
{
public new void hand()
{
Console.WriteLine("Son.hand");
}
static void Main(string[] args)
{
Father son = new Son();
son.hand();
Console.ReadLine();
}
}这个是吧基类中的hand() 隐藏了吧,在Son 类中,,,,,,,运行结果是Father.hand why?
解决方案 »
- 【80分】通过网络url地址获取图片,转换成二进制保存到数据库
- 谁可以帮我把DELPHI代码,传换成C#的啊。谢谢
- C#自动生成编号的问题
- 如何能防止光标在DataGrid中移动?
- 如何得到dataGridView网格内字符位置
- 如何在C#中输出数据表的单一字段值?
- 判断字符串长度的函数是什么???
- 错误提示: at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
- MSN.COM 的EMAIL,能在OUTLOOK2000里接收和发送吗?POP3和SMTP是多少?
- 请教如何制作封面
- 一个进程中的窗口能不能嵌套另一进程中窗口?
- 关于HttpWebRequest的用法,高手们来看看@
New关键字主要用来区别派生类和基类同名方法的选择问题,通过隐藏基类方法,达到使编译器调用正确的方法的目的。Override主要用来对基类的方法和虚方法进行重写
override 是把重写,,,这个是对的。
调用哪个hand()是根据定义的类型来确定,而不是根据实际对象来确定申明的Father,所以调用的就是Father类的hand()方法