资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

35.C#--方法的重载

    //方法重载,简单说就是函数或者方法有相同的名称,但是参数列表不相同;                //这样的同名不同参数的函数或者方法之间,我们称之为重载函数或者方法;
            //main函数中调用的时候,虽然方法名字相同,但根据参数表可以自动调用对应的 函数。
            public static void M(int n1, int n2)
    {
        int result = n1 + n2;

    }
    //public static int M(int a1, int a2)
    //{
    //    return a1 + a2;
    //}
    public static double M(double d1, double d2)
    {
        return d1 + d2;
    }
    public static void M(int n1, int n2, int n3)
    {
        int result = n1 + n2 + n3;
    }
    public static string M(string s1, string s2)
    {
        return s1 + s2;
    }

本文标题:35.C#--方法的重载
转载来于:http://cdkjz.cn/article/isghhs.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220