- //param 关键字可以在调用时用逗号分隔开
- public static voidMain(string[] args)
- {
- Console.WriteLine("Hello World!");
- varresult=GetTotal(1,2,3);
- Console.Write("Press any key to continue . . . "+result);
- Console.ReadKey(true);
- }
- public static intGetTotal(params int[] inputArry)
- {
- intvalue=0;
- for(inti=0;i)
- value+=inputArry[i];
- return value;
- }
来源: http://www.bubuko.com/infodetail-1967790.html