如果形参表中包含了数组型能数,那么它必须在参数表中位于最后。另外,参数只允许是矩阵型。数组型参数不能再有ref和out修饰符。
// 数组参数演示
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();
}
}