:参数个数,参数类型等都不确定~~~但调用的时候,能随便用的(假设会调用很多次,重写方法不适用)函数的类型能不能定义成object型?改怎么写?会的请教教我,谢谢
:参数个数,参数类型等都不确定~~~但调用的时候,能随便用的(假设会调用很多次,重写方法不适用)
2006-08-24 15:49
2006-08-24 16:36
2006-08-24 16:58
[此贴子已经被作者于2006-8-24 17:12:56编辑过]

2006-08-24 17:06
2006-08-24 17:44
2006-08-25 18:24
2006-08-26 09:25

2006-08-26 12:11
public static void UseParams(params object[] arry)
{
for (int i = 0 ; i < arry.Length; i++)
{
Console.WriteLine(arry[i]);
}
Console.WriteLine();
}
static void Main(string[] args)
{
UseParams(1, 'x', "jx");
UseParams(1,10,100,1000);
Console.Read();
}
-------------------------------
不好意思,是我说的不清楚,虚张声势了.其实我就是想实现以上的效果.终于找到了params关键字了.
刚学不久,请勿见笑~~~
2006-08-26 12:49
括弧搞错了..
public static void UseParams(params object[] arry)
{
for (int i = 0 ; i < arry.Length; i++)
{
Console.WriteLine(arry[i]);
}
Console.WriteLine();
}
static void Main(string[] args)
{
UseParams(1, 'x', "jx");
UseParams(1,10,100,1000);
Console.Read();
}
2006-08-26 12:51