在类里面泛型字符串数组打印出来就正常,回到调用它的主程序里面打印,这个泛型数就自动变成一样的啦?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
public List<String[]> SelectNums = new List<string[]>();
private string[] nums = new string[7];
Random ra = new Random();
public void Sjs(int item)
{
Random ra = new Random();
for (int i = 0; i < item; i++)
{
for (int z = 0; z < 7; z++)
{
this.nums[z] = ra.Next(10).ToString();
}
this.SelectNums.Add(nums);
for (int z = 0; z < 7; z++)
{
Console.Write(this.SelectNums[i][z]+" ");
}
Console.ReadLine();
}
}
static void Main(string[] args)
{
Program li = new Program();
li.Sjs(2);
for (int i = 0; i < 2; i++)
{
Console.Write("返回 ");
for (int z = 0; z < 7; z++)
{
Console.Write(li.SelectNums[i][z] + " ");
}
Console.ReadLine();
}
}
}
}