开发者

adding arraylist to another arraylist with different values

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 a开发者_如何学运维n single ArrayList?


Try this

array1.AddRange(array2);


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?


Linq style:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜