Merging Different Array lists into a Single Array list

//First Add System.Collections Name Space In order to Access Array list Class.
//I have Taken 2 Arraylist i.e., arr,arr1. We can take any no. of Array lists
Array List arr = new Array List();
arr.Add("mohan");
arr.Add("shanthi");
Array List arr1 = new Array List();
arr1.Add(1);
arr1.Add(2);
//I have taken another arraylist in which above 2 arraylist items are copied.
ArrayList totarr = new ArrayList();
totarr.AddRange(print(arr, arr1));
//In this method all arraylist items are combined & returned to main where they are added to Arraylist.
static Queue print(params ICollection[] arrayitems)
{
Queue iq = new Queue();
for (int i=0;i {
IEnumerator allitems = arrayitems[i].GetEnumerator();
while (allitems.MoveNext())
{
iq.Enqueue(allitems.Current);
}
}
return iq;
}


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: