 |
|
ช่วยแปลง VB.NET เป็น C# ให้หน่อยครับ เกี่ยวกับการเรียก Sub จาก ตัวมันเอง |
|
 |
|
|
 |
 |
|
ผมมี Code อยู่ แต่ไม่เข้าใจ ว่า บรรทัดนี้ มัน ไปเรียกชื่อตัวเอง ทำงายอย่างไรครับ
FillHTMLTreeRecursive( olParent.Add( ol), ref htmlString, ref pdfDoc);
อยากรบกวน CONVERT เป็น C# ให้ด้วย
Code VB.NET
Code
Public Shared Sub FillHTMLTreeRecursive(ByVal olParent As PDFLibNet.OutlineItemCollection(Of PDFLibNet.OutlineItem), ByRef htmlString As String, ByRef pdfDoc As PDFLibNet.PDFWrapper)
htmlString &= "<ul>"
For Each ol As PDFLibNet.OutlineItem In olParent
htmlString &= "<li><a href=""javascript:changePage('" & ol.Destination.Page & "')"">" &
Web.HttpUtility.HtmlEncode(ol.Title) & "</a></li>"
If ol.KidsCount > 0 Then
FillHTMLTreeRecursive(ol.Childrens, htmlString, pdfDoc)
End If
Next
htmlString &= "</ul>"
End Sub
ลองแปลงเป็น C# แล้ว Error
Code
public static void FillHTMLTreeRecursive(
PDFLibNet.OutlineItemCollection<PDFLibNet.OutlineItem> olParent
, ref string htmlString
, ref PDFLibNet.PDFWrapper pdfDoc)
{
htmlString += "<ul>";
foreach (PDFLibNet.OutlineItem ol in olParent)
{
htmlString += "<li><a href=\"javascript:changePage('" + ol.Destination.Page + "')\">" + System.Web.HttpUtility.HtmlEncode(ol.Title) + "</a></li>";
if (ol.KidsCount > 0)
{
FillHTMLTreeRecursive( olParent.Add( ol), ref htmlString, ref pdfDoc);
}
}
htmlString += "</ul>";
}
Tag : .NET, VB.NET, C#
|
|
 |
 |
 |
 |
Date :
2014-10-07 14:08:55 |
By :
jomy.nn |
View :
920 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
vb.net
Code (VB.NET)
FillHTMLTreeRecursive(ol.Childrens, htmlString, pdfDoc)
C#
Code (C#)
FillHTMLTreeRecursive(olParent.Add(ol), ref htmlString, ref pdfDoc);
ทำไมไม่เหมือนกันครับ ไม่น่าจะ add นะครับ ควรเป็น ol.Childrens
|
 |
 |
 |
 |
Date :
2014-10-07 15:48:04 |
By :
gunnermontana |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|