如何阅读arraylists的arraylist? [英] How to read arraylist of arraylists?

查看:87
本文介绍了如何阅读arraylists的arraylist?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有ArrayList的ArrayList,如何显示每个ArrayList的值。例如,如果我有包含arraylists(b,c,d)的arraylist,我如何读取ArrayLists b,c和d的值。

I have ArrayList of ArrayLists, how can I display the values of each ArrayList. For example if I have arraylist a that contain arraylists (b,c,d), how can I read the values of ArrayLists b, and c and d.

推荐答案

你所要做的就是遍历你的ArrayList,然后遍历你正在循环的ArrayList :)

All you have to do is loop through your ArrayList and then loop through your ArrayList that you're looping through :)
ArrayList arr = new ArrayList();
arr.Add(new ArrayList(new[] { "value 1.1", "value 1.2" }));
arr.Add(new ArrayList(new[] { "value 2.1", "value 2.2" }));
arr.Add(new ArrayList(new[] { "value 3.1", "value 3.2" }));
foreach (ArrayList innerArr in arr)
{
	foreach (object element in innerArr)
	{
		// Do something with the elements.
	}
}

我建议你看一下列表< T> [ ^ ]类虽然?

May I suggest you take a look at the List<T>[^] class though?


这篇关于如何阅读arraylists的arraylist?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆