110,533
社区成员
发帖
与我相关
我的任务
分享
int[] a = { 1, 2, 3, 4, 5 };
int[] b = { 6, 7, 8, 9 };
int[] c = { 10, 11, 12 };
for (int i = 0; i < 5; i++)
for (int j = 0; j < 4; j++)
for (int k = 0; k < 3; k++)
Console.WriteLine(a[i] + "," + b[j] + "," + c[k]);
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{
int[][] aa = new int[4][];
int[] a = { 1, 2, 3, 4, 5 };
int[] b = { 6, 7, 8, 9 };
int[] c = { 10, 11, 12 };
int[] d ={ 13, 14 };
aa[0] = a;
aa[1] = b;
aa[2] = c;
aa[3] = d;
myClass ff = new myClass(aa);
ff.mySelf();
ArrayList dataSource = ff._firstList;
for (int i = 0; i < dataSource.Count; i++)
listBox1.Items.Add(dataSource[i].ToString());
}
}
class myClass
{
int[][] intList;
ArrayList firstList=new ArrayList();
public ArrayList _firstList
{
get
{
return this.firstList;
}
}
public myClass(int[][] intList)
{
this.intList = intList;
firstList.AddRange(intList[0]);
}
public void mySelf()
{
for (int i = 1; i < intList.Length;i++ )
Display(intList[i]);
}
string strCount;
private void Display(int[] list)
{
strCount = string.Empty;
for (int i = 0; i < firstList.Count; i++)
{
for (int j = 0; j < list.Length; j++)
{
strCount += firstList[i].ToString() + list[j].ToString() + "&";
}
}
firstList.Clear();
firstList.AddRange(strCount.Split('&'));
firstList.RemoveAt(firstList.Count - 1);
}
}