I need a quick hand figuring out what this code is doing, and how to make it work in vb.net
我需要快速找出这段代码的作用,以及如何使它在vb.net中运行
<%=Html.PageLinks((int(ViewData["CurrentPage"], (int)ViewData["Totalpages"], x=> Url.Action("List", new {page = x})) %>
i've figured out most of it. but the x=>Url.Action("List", new {page = x}) part is throwing me off. I tried reading about lamdas and such but i'm not quite getting it.
我已经弄清楚了大部分内容。但是x => Url.Action(“List”,新的{page = x})部分让我失望。我试着阅读lamdas等等,但我并没有得到它。
the pagelinks is defined like this:
pagelinks的定义如下:
_
Public Function PageLinks(ByVal html As HtmlHelper, ByVal currentPage As Integer, ByVal totalPages As Integer, ByVal pageUrl As Func(Of Integer, String)) As String
Dim result As New StringBuilder
For i As Integer = 1 To totalPages
Dim tag As New TagBuilder("a")
tag.MergeAttribute("href", pageUrl(i))
tag.InnerHtml = i.ToString
If i = currentPage Then
tag.AddCssClass("selected")
End If
result.AppendLine(tag.ToString())
Next
Return result.ToString
End Function
which i THINK is the correct conversion from c#.
我认为是从c#正确的转换。
Thanks in advance!
提前致谢!
Patricia
1 个解决方案
#1
I believe the correct conversion of C#:
我相信C#的正确转换:
x=> Url.Action("List", new {page = x})
would be in VB.Net:
将在VB.Net:
Function(x) Url.Action("List", New With {.page = x})
#1
I believe the correct conversion of C#:
我相信C#的正确转换:
x=> Url.Action("List", new {page = x})
would be in VB.Net:
将在VB.Net:
Function(x) Url.Action("List", New With {.page = x})