首页 > Windows开发 > 详细

C#方法的重载

时间:2015-05-10 16:59:28      阅读:284      评论:0      收藏:0      [点我收藏+]

方法的重载

参数不同,个数可以相同

参数相同,个数不能相同

        static void Main(string[] arr)
        {
            Console.WriteLine(M(2,3));
            Console.ReadKey();
        }

        public static int  M(int n1, int n2)
        { 
            n1=n1+n2;
            return n1;
        }
        public static string M(string s1, string s2)
        {
            s1 = s1 + s2;
            return s1;
        }
        public static int M(int n1, int n2,int n3)
        {
            n1 = n1 + n2+n3;
            return n1;
        }

 

C#方法的重载

原文:http://www.cnblogs.com/zywf/p/4492355.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!