我有一个 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/