开发者

Aggregate on dictionary question

开发者 https://www.devze.com 2023-01-04 13:01 出处:网络
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:

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?


Use this:

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, Kris.

0

精彩评论

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