开发者

Linq and Dictionary and converting array values

I have the following code

IDictionary<string, IEnumerable<Control>>
开发者_Python百科

I need to convert it to

IDictionary<string, IEnumerable<string>>

using ClientID as the new value.

Does anybody know how to do this in Linq instead iterating through the dictionary?

Thanks

Podge


Something like

IDictionary<string, IEnumerable<Control>> input = ...
IDictionary<string, IEnumerable<string>> output = 
    input.ToDictionary(item => item.Key,
                       item => item.Value.Select(control => control.ClientID)); 


Without having a compiler by hand, something like this should work...

dictOne
  .ToDictionary(k=>k.Key, v=>v.Value.Select(c=>c.ClientID))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜