C#数组传递和返回

 class Program
{
static void Main()
{
int[] it = new int[10];
for (int i = 0; i < it.Length; i++)
{
Console.WriteLine(it[i]);
}

int[] oldim = new int[it.Length];
Array.Copy(it, oldim, it.Length);//对原始数组的浅拷贝,返回对新数组的引用。
test(oldim);//000000。。
test(it);//123456.。。
for (int i = 0; i < it.Length; i++)
{
Console.WriteLine(it[i]);
}
//int[] ildim = new int[5];

Console.ReadKey();
}
static void test(int[] i)
{
for (int n = 0; n < i.Length; n++)
{
i[n] = n;
}
}
}
posted @ 2011-12-21 14:32  Rookier  阅读(686)  评论(0编辑  收藏  举报