日期:2014-05-18 浏览次数:20829 次
using System; public class MyMath { public static long Add(params int[] args) { int ctr=0; long Answer=0; for (ctr=0; ctr<args.Length;ctr++) { Answer +=args[ctr]; } return Answer; } public static long Subtract(int arg1, int arg2) { long Answer=0; Answer=arg1-arg2; return Answer; } } class MyAp { public static void Main() { MyMath math=new MyMath(); long Result=0; Result=math.Add(1,2,3); Console.WriteLine("Add result is {0}", Result); Result=math.Subtract(5,2); Console.WriteLine("Subtract result is {0}",Result); } }