明辉手游网中心:是一个免费提供流行视频软件教程、在线学习分享的学习平台!

C#中方法参数的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();

}

}