Iteratate List of Dictionay [英] Iteratate Dictionay of List

查看:49
本文介绍了Iteratate List of Dictionay的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个这样的词典:


Dictionary< List< string> ;, List< string>>


如何迭代它?


非常感谢。

-

Luigi

Hi all,
I have a dictionary like this:

Dictionary<List<string>, List<string>>

How can I iterate in it?

Thanks very much.
--
Luigi

推荐答案

那么,你想要迭代什么?每个键(一个List< string>)可能有多个
多个valies - 你只想要这些值吗?


使用C#3.0 / .NET 3.5,SelectMany是一个选项,但我想(最后发表)

这不是一个选择。所以你只需要几个嵌套的foreach循环。


Marc
Well, what do you want to iterate? Each key (a List<string>) could have
multiple valies - do you just want the values?

With C# 3.0 / .NET 3.5, SelectMany is an option, but I guess (last post)
that this isn''t an option. So you''ll just need a few nested foreach loops.

Marc


" Marc Gravell"写道:
"Marc Gravell" wrote:

嗯,你想要迭代什么?每个键(一个List< string>)可能有多个
多个valies - 你只想要这些值吗?


使用C#3.0 / .NET 3.5,SelectMany是一个选项,但我想(最后发表)

这不是一个选择。所以你只需要几个嵌套的foreach循环。
Well, what do you want to iterate? Each key (a List<string>) could have
multiple valies - do you just want the values?

With C# 3.0 / .NET 3.5, SelectMany is an option, but I guess (last post)
that this isn''t an option. So you''ll just need a few nested foreach loops.



是的,我正在使用C#2.0,因此禁止使用许多有用的选项。

我想要的是获取我字典中

第一个列表的每个字符串的字符串集合。


Luigi

Yes, I''m using C# 2.0, so many useful options are prohibited for me.
What I''d like is to obtain the collection of strings for every string of the
first List in my dictionary.

Luigi


是的,我正在使用C#2.0,因此禁止使用许多有用的选项。
Yes, I''m using C# 2.0, so many useful options are prohibited for me.

我想要的是获取字典中

第一个List的每个字符串的字符串集合。
What I''d like is to obtain the collection of strings for every string of the
first List in my dictionary.



你能举一个简单的例子吗?


ie

" if数据有点膨胀,然后我想{你的位在这里}


第1项:键(列表)" a"," b"

值(列表)c,d,e

项目2:密钥(列表)" f"

value(list)" g"," h"


Marc

Can you show that with a simple example?

i.e.
"if the data was as bloe, then I want {your bit here}

item 1: key (list) "a", "b"
value (list) "c", "d", "e"
item 2: key (list) "f"
value (list) "g", "h"

Marc


这篇关于Iteratate List of Dictionay的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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