简单c#数组问题求助
using System;
using lwpclass;
namespace Lwping
{
class lwp1
{
static void Main(String[] args)
{
int[] la ={1,2,3,4,5};
int[] lb ={4,5,6,7,8};
int[] lab;
}
}
}
求 la与lb的并集lab
参考答案:int[] la ={ 1, 2, 3, 4, 5 };
int[] lb ={ 4, 5, 6, 7, 8 };
System.Collections.ArrayList lab = new System.Collections.ArrayList();
for (int m = 0; m < la.Length; m++)
{
for (int n = 0; n < lb.Length; n++)
{
if (la[m] == lb[n])
{
lab.Add (la[m]);
}
}
}