using System;
public class MyClass
{
public static void UseParams(params int[] list)
{
for(int i=0;i<list.Length;i++)
{
Console.WriteLine(list[i]);
}
Console.WriteLine();
}
public static void UseParams2(params object[] list)
{
for(int i=0;i<list.Length;i++)
{
Console.WriteLine(list[i]);
}
Console.WriteLine();
}
static void Main()
{
UseParams(1,2,3);
UseParams(1,2,3,4,5);
UseParams2(1,'a',"test");
UseParams2(1,'a',"test","Chinese","English");
int[] myarray=new int[3]{10,11,12};
UseParams(myarray);
}
}
/----------------------------------程序输出结果-------------------------------------------/
1
2
3
1
2
3
4
5
1
a
test
1
a
test
Chinese
English
10
11
12
/----------------------------------程序输出结果-------------------------------------------/
|