c# - 如何访问列表中的特定列表?

标签 c# list sublist

我有一个 List<List<string>>信息;那是另外 3 个列表。我需要能够在这些子列表中的每一个上做三件不同的事情。我如何访问每个子列表?

为了更加清晰,列表已添加到主列表中,如下所示

infomration.Add(sublist1);//where each sublist is a List<string> and information is a <List<List<string>>
infomration.Add(sublist2);
infomration.Add(sublist3);
reutrn information;

最佳答案

您希望对列表中的 3 个元素(列表)执行 3 个独立的操作。既然 Lists 是有索引的,为什么不以这种方式访问​​它们呢?

PerformOperationOne(myListofLists[0]);
PerformOperationTwo(myListofLists[1]);
PerformOperationThree(myListofLists[2]);

关于c# - 如何访问列表中的特定列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13681734/

相关文章:

c# - NamedPipeClientStream 在应用程序服务中不起作用

c# - 从页面方法加载文件

c# - RegisterClientScriptBlock参数在真实场景中的用法?

C# 到 MusicXML?

python - 我有三个单独的列表,我想按顺序连接它们

java - 2D 列表中的子列表,引用

python - 如何 random.shuffle 切片或对象列表的子集?

python - 将文件数据转换为嵌套列表

python - 如何使用 Python 从另一个列表中按列表项划分列表项?

python - 如何使用正则表达式检查两个子列表列表之间是否存在匹配?