// 数组参数演示
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();
}
}
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();
}
}
引用自:
http://www2.cnblogs.com/netfork/archive/2004/03/22/3858.html