如何在c#中复制数组[重复]

问题描述 投票:0回答:1

我有5个数组,我想将这些数组做成一个数组,所以当我得到1号tu时,选择1号数组来显示。我想要实现这样的效果;

public String [] array1={"one","two","tree","four"};
public String [] array2={"five","six","seven","eight"};
public String [] array3={"nine","ten","eleven","twelve"};
public String [] array3={"thirteen","fourteen","fifteen","sixteen"};

所以现在有int i = 1;点击增加int,i + = 1;然后显示编号为i

的数组中的相应文本
c# arrays
1个回答
3
投票
int[] list1 = new int[4] { 1, 2, 3, 4};
int[] list2 = new int[4] { 5, 6, 7, 8};
int[] list3 = new int[4] { 1, 3, 2, 1 };
int[] list4 = new int[4] { 5, 4, 3, 2 };

int[][] lists = new int[][] {  list1 ,  list2 ,  list3 ,  list4  };

另一种选择是创建列表类型:

List<int[]> data=new List<int[]>(){list1,list2,list3,list4};

Relevant Answer

© www.soinside.com 2019 - 2024. All rights reserved.