I want to merge all data in two arraylist in c#. Some data in arraylist got same with another arraylist. i don't want duplicate data when merge.
ArrayList1 ArrayList2
1 1
2 2
3 4
5
I've try the coding below. but the result not as i expected:
for(int i = 0; i<arrayList2;i++)
{
for(int j = 0; j<arrayList1;j++)
{
if(arraylist1[i] == arraylist2[j])
{
newArraylist.add(arraylist[i]+"-same");
}
else
{
newArraylist.add(arraylist[i]+"-from arrayList2");
}
}
}
The result from code above is :
newArrayList
1 - same
2 - same
4 - from arraylist2
5 - from arraylist2
the result that i want :
newArrayList
1 - same
2 - same
3 - from arraylist1
4 - from arraylist2
5 - from arraylist2
List<T>?from arraylist1when that's not even in your code snippet?