Visual C#Collection"map"功能?

Ale*_*der 5 c# collections map visual-studio

在Haskell中我们有这个功能

map (a -> b) -> [a] -> [b]
Run Code Online (Sandbox Code Playgroud)

使用函数更改集合的类型.

C#中有类似的东西吗?

或者,将完整的KeyValuePairs集合放入调试消息中的最快方法是什么?

我想到了......

debugmsg("http response is " + service.HttpResponseHeaders
                                      .Map<string>((k, v) => k + "->" + v)
                                      .Aggregate((s, sx) => s + "," + sx)
                             + ". ");
Run Code Online (Sandbox Code Playgroud)

Pat*_*iek 8

在LINQ中,map被命名Select.此外,请注意,任何集合KeyValuePair<TKey, TValue>只会有一个参数Select; 你必须拉KeyValue出来.

service.HttpResponseHeaders.Select(kvp => kvp.Key + "->" + kvp.Value)
                           .Aggregate((s, sx) => s + "," + sx);
Run Code Online (Sandbox Code Playgroud)