zoukankan      html  css  js  c++  java
  • 重载OverLoad。隐藏new

    <1>

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Test
    {
    
        class A
        {
            public void SayHello()
            {
                Console.WriteLine("我是父类的SayHello方法");
            }
        }
    
        class B : A
        {
            public new void SayHello() //子类利用newkeyword隐藏了父类的同名方法
            {
                Console.WriteLine("我是子类的SayHello方法");
            }
        }
    
    
        //构成方法重载的条件:<1>:函数名同样  <2>:參数类型不同,或者參数个数不同
        //注意:函数返回值类型的不同 不是函数重载的推断条件。
        class C
        {
            public void Add(int a,int b)   //下面4个Add方法构成了重载
            {
                Console.WriteLine(a + b);
            }
            public double Add(double a, double b)
            {
                return a + b;
            }
            public void Add(int a)
            {
                Console.WriteLine(a);
            }
    
            public string Add(string a, string b)
            {
                return a + b;
            }
        }
        class Inheritance
        {
            static void Main(string[] args)
            {
    
                B b = new B();
                b.SayHello();
    
    
    
                Console.ReadKey();
            }
        }
    }
    

  • 相关阅读:
    图像滤波
    直方图histeq
    直方图
    基于灰度变换的图像增强
    图像增强
    图像旋转和缩放
    图像点运算
    像素的连接与联通
    程序员进阶之算法练习(一)
    RxSwift 系列(二)
  • 原文地址:https://www.cnblogs.com/yxysuanfa/p/7162025.html
Copyright © 2011-2022 走看看