聚集在字典的问题 [英] Aggregate on dictionary question
本文介绍了聚集在字典的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用ASP.NET MVC2,我想弥补基于当前的一个扩展的HtmlHelper里面的地址栏中的URL。到目前为止,我有这样的:
I am using ASP.NET MVC2 and I would like to make up a url based on the current one in the address bar inside a HtmlHelper extension. So far I have this:
url = helper.ViewContext.RequestContext.RouteData.Values
.Aggregate<KeyValuePair<String, Object>>((w, next) => w + next);
但是,这并不编译。任何人有关于如何解决这个聚合函数是个好主意?
But that does not compile. Anyone has a good idea on how to solve this Aggregate function?
推荐答案
使用这样的:
helper.ViewContext.RequestContext.RouteData.Values
.Select(x => x.Value.ToString())
.Aggregate((c, next) => c + next);
不过既然你想要的东西就像一个网址,我建议你使用这样的:
But since you want something like a url I suggest you use this:
helper.ViewContext.RequestContext.RouteData.Values
.Select(x => x.Value.ToString())
.Aggregate((c, next) => c + "/" + next);
GRZ,克里斯。
Grz, Kris.
这篇关于聚集在字典的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文