I have created an htmlhelper which has signature like this:
public static MvcHtmlString PageLinks(this HtmlHelper html,
PagingInfo pagingInfo,Func<int, string> pageUrl)
and I see that It is passed like this:
@Html.PageLinks(Model.PagingInfo, x => Url.Action("List", new {page = x}))
but I dont know what is it meaning ?
x => Url.Action("List", new {page = x})
Please suggest meaning of this lambda expression
Well, it’s a lambda expression which takes a single parameter called
xand is implicitly typed to be aint, and which callsUrl.Actionwith one argument of the string"List"another argument of an anonymous type which has a single propertypagewith the value of the parameterx.The value returned from
Url.Actionis used as the return value for the lambda expression.That’s how the lambda expression itself is broken down, in terms of language constructs. If you’re asking what it means in terms of behaviour, that’s a different matter – you’d need to look at your own
PageLinksmethod, as well as the documentation forUrl.Action.