c# 合并两个有序数组

时间:2023-03-09 01:57:37
c# 合并两个有序数组
 int[] ints1 = new int[] { , , , , ,  };
int[] ints2 = new int[] { , , , };
ArrayList lists = new ArrayList();
ArrayList temp = new ArrayList();
lists.AddRange(ints1);
temp.AddRange(ints2);
for (int i = ; i < lists.Count; i++)
{
if (temp.Count > )
{
var strs2First = temp[];//取第一个元素
if (Int32.Parse(lists[i].ToString()) >= Int32.Parse(strs2First.ToString()))
{
lists.Insert(i, strs2First);
temp.RemoveAt();
}
else if (Int32.Parse(lists[lists.Count - ].ToString()) < Int32.Parse(strs2First.ToString()))
{
lists.Insert(lists.Count, strs2First);
temp.RemoveAt();
}
}
}