zoukankan      html  css  js  c++  java
  • c#隐藏和重写基类方法的区别

    c#隐藏和重写基类方法的区别

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace interfaceInfo
    {
        public class animal
        {
            public void action()
            {
                Console.WriteLine("eat sleep fuck");
            }
    
            public virtual void show()
            {
                Console.WriteLine("show...");
            }
        }
        public class dog : animal
        {
            public new void action()
            {
                Console.WriteLine("new...");
            }
    
            public override void show()
            {
                Console.WriteLine("override");
            } 
    
    
    
        }
        class Program
        {
            static void Main(string[] args)
            {
                dog d = new dog();
                d.action();  //new...
                d.show();   //override
    
                Console.ReadLine();
    
                animal an = new dog();
                an.action();  //  eat sleep fuck
                an.show();    //  override
    
                Console.ReadLine();
               
            }
        }
    }
  • 相关阅读:
    jquery operate
    ujs
    图标站
    rails foreign key
    feedback product from uservoice
    秒杀网
    short url
    rails nil blank
    paperclip imagemagic api &paperclip relevent
    类似优米网
  • 原文地址:https://www.cnblogs.com/mc67/p/5008370.html
Copyright © 2011-2022 走看看