粗略的讲我只知道,Base 是子类中引用父类.但是我昨天看了个例题:using System;namespace 实验base
{
    class Automobile : Object
    {
        public override string ToString()
        {
            string tmp="试下base返回值出呼意料Look at here:"+base.ToString();
            return  tmp;            
        }
    }    class Program
    {
        static void Main(string[] args)
        {
            Automobile myAutomobile = new Automobile();
            Console.WriteLine(myAutomobile.ToString());
            Console.Read();
        }
    }
}//结果居然输出:试下base返回值出呼意料Look at here:实验base.Automobile
//怎么不是输出:试下base返回值出呼意料Look at here:Object呢?
msdn里这个讲解好象没挨上边.大家帮我解释下啊!

解决方案 »

  1.   

    base就是基类实例...Automobile的ToString()方法没有重写,当然输出它自己的类名凭什么输出“Object”呢?,这还能有疑问吗?好好看书...
      

  2.   


    public class Object
    {
      public virtual string ToString()
      {
        return this.GetType().ToString();    //<--
      }
    }
    这是object.ToString的默认实现,其中GetType()获取当前实例的类型,是由CLR负责的一个函数。在你的例子中,this.GetType()就是"实验base.Automobile"。 
      

  3.   

    override “遮挡”父类的方法,使用父类引用调用时,调用子类的方法。
      

  4.   

    今天运气不错,都是二星级帮我解决,Thank you all of you!三楼的让我明白了为什么了.
      

  5.   

    就是这个原因...GetType方法返回“表示当前实例的确切运行时类型”...也就是说除非是无确切运行时类型的object实例,否则不包括Object,即使你用base显式指定...另外...所有对象都继承自object,不需要显式继承...