MyException - 我的异常网
当前位置:我的异常网» C# » 隔代访问?

隔代访问?

www.MyException.Cn  网友分享于:2013-12-27  浏览:2次
隔代访问??
class MyBase
  {
  public void Fun1()
  {
  Console.WriteLine("base");
  }
  }
  class MyDerived : MyBase
  {
  new public void Fun1()
  {
  Console.WriteLine("Derived");
  }
   
  }
  class MyDerived2 : MyDerived
  {
  public void Fun5()
  {
  base.Fun1();???????如何访问Mybase中的Fun1()??????
  }
  }

------解决方案--------------------
C# code

class MyBase 
    { 
        public void Fun1() 
        { 
            Console.WriteLine("base"); 
        } 
      } 
    class MyDerived : MyBase 
    { 
        new public void Fun1() 
        { 
            Console.WriteLine("Derived"); 
        }
                
    } 
    class MyDerived2 : MyDerived 
    { 
        public void Fun5() 
        {
            ((MyBase)this).Fun1();
        } 
    }

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有