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?
解决方案 »
- 有没有人知道文字变线条的算法的
- datagridview 点击列的问题
- 使用ado.net的olddb的方式读取excel为何多出一些空白列呢?
- 如何将一篇英文文章打散成单词集合
- 求正则表达 要求有点怪的 仔细看题目 100分献上
- 兄弟,如果你够朋友的话,都进来帮我解决下关于NHibernate的问题.........
- 我想搞个小东东来同步两个不同地方的数据库,但用的方法很费时?大家帮看看还有什么更好的方法吗?
- 如何使用多线程技术来读取数据库记录并利用读取的记录数据进行其他数据处理?(内有说明)
- c#邮件发送速度问题
- wpf无边框窗体最小化问题
- 一个进程中的窗口能不能嵌套另一进程中窗口?
- 关于HttpWebRequest的用法,高手们来看看@
New关键字主要用来区别派生类和基类同名方法的选择问题,通过隐藏基类方法,达到使编译器调用正确的方法的目的。Override主要用来对基类的方法和虚方法进行重写
override 是把重写,,,这个是对的。
调用哪个hand()是根据定义的类型来确定,而不是根据实际对象来确定申明的Father,所以调用的就是Father类的hand()方法