C# ArrayList 的数组列表 [英] C# Array List of ArrayList

查看:44
本文介绍了C# ArrayList 的数组列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串对象的数组列表,然后将其添加到数组列表的数组列表中.

I have an arraylist of string objects, that then gets added into and arraylist of arraylists.

作为 Java 开发人员,我曾经使用过 Vectors,我知道现在已经不复存在了,但这个名字听起来很棒哈哈!!,我还使用了 ArrayList,它们都可以通过例如访问子数组列表

As a java developer I used to use Vectors, I know now defunct but the name sounds great haha!!, I also used ArrayList which both had access to the sub arraylist by means of, for example

ArrayList<String> array1 = new ArrayList<String>();
array.add("test");

ArrayList<ArrayList> array2 = new ArrayList<ArrayList>()
array2.add(array1);

string var = array2.get(1).get(2);

C# 中的等效项是什么?

What is this equivilent in C#?

推荐答案

您想使用 List 泛型类:

List<string> array1 = new List<string>();
array1.Add("test");

List<List<string>> array2 = new List<List<string>>();
array2.Add(array1);

string myStr = array2[0][0]; //Whatever indexers you want here

这篇关于C# ArrayList 的数组列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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