Questions on Linq, Anonymous Type Object RRS feed

  • Question

  • Hi everyone,

    I am studying MVC and was following an example. I am also not expert with Lambda expressions and ANonymous types, although I have read and know the basics. However I got trapped and could not continue. I need help about this code snippets below. Can someone please answer my question ?

    1. how the X was inferred to be an INT ?

    2. What is the return of "new {  page = x }" ?

    3. What is the return of "Url.Action("List", new {  page = x })" ?

    4. What is the return of "x => Url.Action("List", new {  page = x })" ?

    5. This call, pageUrl(i), what does it do and where is the method declared ?

    <div class="pager">   
        @Html.PageLinks(Model.PagingInfo, x => Url.Action("List", new {  page = x })) 


     public static MvcHtmlString PageLinks(this HtmlHelper html, PagingInfo pagingInfo, Func<int, string> pageUrl) 
                StringBuilder result = new StringBuilder();
                for (int i = 1; i <= pagingInfo.TotalPages; i++)
                    TagBuilder tag = new TagBuilder("a"); // Construct an <a> tag
                    tag.MergeAttribute("href", pageUrl(i));
                    tag.InnerHtml = i.ToString();

                    if (i == pagingInfo.CurrentPage)


                return MvcHtmlString.Create(result.ToString());


    Thank you so much.

    Sunday, August 24, 2014 3:16 AM


  • Hi CodeInhinyero,

    Actually this forum is to discuss the VS usage issue, if this issue is related to web development, you could ask this question in the ASP.NET forum: http://forums.asp.net. If then, you could get an answer more quickly and professional.

    The MVC forum:


    Best Regards,

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    Monday, August 25, 2014 2:59 AM