码迷,mamicode.com
首页 > Windows程序 > 详细

C#方法的重载

时间:2015-05-10 17:02:15      阅读:131      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!