温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

35.C#--方法的重载

发布时间:2020-05-20 19:40:39 来源:网络 阅读:324 作者:初禾 栏目:编程语言
    //方法重载,简单说就是函数或者方法有相同的名称,但是参数列表不相同;                //这样的同名不同参数的函数或者方法之间,我们称之为重载函数或者方法;
            //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;
    }
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI