主题:帮忙解释一下这段程序的意思谢谢
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication6
{
class Program
{
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((object)list[i]);
Console.WriteLine();
}
static void Main(string[] args)
{
Useparams(1);
Useparams(1, 2, 3);
Useparams2(1, 'a', "test");
int[] myarray = new int[3] { 10, 11, 12 };
Useparams(myarray);
}
}
}
这段程序是什么意思呀..
特别是
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((object)list[i]);
Console.WriteLine();
}
这部分
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication6
{
class Program
{
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((object)list[i]);
Console.WriteLine();
}
static void Main(string[] args)
{
Useparams(1);
Useparams(1, 2, 3);
Useparams2(1, 'a', "test");
int[] myarray = new int[3] { 10, 11, 12 };
Useparams(myarray);
}
}
}
这段程序是什么意思呀..
特别是
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((object)list[i]);
Console.WriteLine();
}
这部分