c#继承中的函数调用实例
2021-04-23 16:53
                         标签:模拟登陆   null   float   sts   div   base   style   turn   ase     本文实例讲述了c#继承中的函数调用方法,分享给大家供大家参考。具体分析如下:  首先看下面的代码:    namespace Test  {  public class Base  {  public void Print()  {  Console.WriteLine(Operate(8, 4));  }  protected virtual int Operate(int x, int y)  {  return x + y;  }  }  }  namespace Test  {  public class OnceChild : Base  {  protected override int Operate(int x, int y)  {  return x – y;  }  }  }  namespace Test  {  public class TwiceChild : OnceChild  {  protected override int Operate(int x, int y)  {  return x * y;  }  }  }  namespace Test  {  public class ThirdChild : TwiceChild  {  }  }  namespace Test  {  public class ForthChild : ThirdChild  {  protected new int Operate(int x, int y)  {  return x / y;  }  }  }  namespace Test  {  class Program  {  static void Main(string[] args)  {  Base b = null;  b = new Base();  b.Print();  b = new OnceChild();  b.Print();  b = new TwiceChild();  b.Print();  b = new ThirdChild();  b.Print();  b = new ForthChild();  b.Print();  }  }  }  本文地址:  http://www.paobuke.com/develop/c-develop/pbk23196.html c#继承中的函数调用实例 标签:模拟登陆   null   float   sts   div   base   style   turn   ase    原文地址:http://www.cnblogs.com/paobuke/p/7994910.html
 代码如下:
   c#继承中的函数调用实例相关内容




上一篇:C#语音识别用法实例
下一篇:C#的winform控件命名规范