明輝手游網(wǎng)中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

C#中方法參數(shù)的4種分類

[摘要]using System; class Test static void F(params int[] args) Console.WriteLine("Array contains 0 elements:",args...

using System;

class Test

{

       static void F(params int[] args)

       {

              Console.WriteLine("Array contains {0} elements:",args.Length);

              foreach(int i in args)

                     Console.Write("{0}",i);

              Console.WriteLine();

       }

       public static void Main()

       {

              int [] a = {1,2,3};

              F(a);

              F(10,20,30,40);

              F();

}

}