位置:首頁(yè) > 軟件操作教程 > 編程開發(fā) > C# > 問(wèn)題詳情

重載方法的調(diào)用

提問(wèn)人:劉冬梅發(fā)布時(shí)間:2020-10-13

using system;

namespace TestAdd

{

     public class TestAdd

 {

         public int Add(int a,int b)  {return a+b;}

         public double Add(double a,double b)  {return a+b;}

         public int Add(string a,string b)  

         {return Convert.ToInt32(a)+ Convert.ToInt32(b);}

     }

      class Test

     {

          public static void Main( )

          {

             TestAdd t=new TestAdd( );

             t.Add(1,2);

             t.Add(2.0,3.0);

             t.Add(“3”, “4”);

             t.Add(2,3.0);

             t.Add(“2”,3.0);

            }

      }

}


繼續(xù)查找其他問(wèn)題的答案?

相關(guān)視頻回答
回復(fù)(0)
返回頂部