1

I have a dataset with 2 tables, so I declared 2 ArrayList and fetching that table values from DataSet into two ArrayLists.

One ArrayList has the count of 66, another of 37.

Now, how do I combine these ArrayLists into one ArrayList so that I get values of both ArrayList into an single ArrayList?

3 Answers 3

3

Try this

array1.AddRange(array2);
Sign up to request clarification or add additional context in comments.

Comments

2

You can use the AddRange method. But you shouldn’t use ArrayLists, they are deprecated. Use the generic List class instead.

Furthermore, are you sure you need the separate values at all? Aren’t the data sets enough?

Comments

0

Linq style:

IList<int> both = arrlist1.Cast<int>().Concat(arrlist2.Cast<int>()).ToList();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.