数组排序
功能:多个数组,排列,从功以上来说网上该有现成的例子。。。
找到的全是写得很复杂,自己写了一个。
List<string> ToDo(string[] arrA, string[] arrB)
{
List<string> resultList = new List<string>();
//string[] arrA = { "a", "b" };
//string[] arrC = { "a", "d" };
foreach (string str in arrA)
{
foreach (string st in arrB)
{
resultList.Add(str + st);
}
}
return resultList;
}
public void Test()
{
List<string> aa = new List<string> { "a", "b" };
List<string> bb = new List<string> { "c", "d" };
List<string> cc = new List<string> { "e", "f", "g" };
List<List<string>> resultList = new List<List<string>>();
resultList.Add(aa);
resultList.Add(bb);
resultList.Add(cc);
List<string> result = new List<string>();
for (int i = 0; i < resultList.Count - 1; i++)
{
if (result.Count == 0)
{
result = ToDo(resultList[i].ToArray(), resultList[i + 1].ToArray());
}
else
{
result = ToDo(result.ToArray(), resultList[i+1].ToArray());
}
}
}
-------此处无银三百两------

浙公网安备 33010602011771号