我见过other posts,但它们大多是在C#中实现的。对于希望学习递归的人来说,看看VB.Net中的实际工作示例可能会很有帮助。如果有人刚刚接触VB.Net编程,尝试破译和convert C#是一个额外的困难。我确实找到了我现在理解的this post,但如果有一篇VB.Net示例的帖子,我可能已经能够找到它了,faster.This是我提出这个问题的部分原因:
有没有人可以在VB.Net中展示一些简单的递归函数示例?
发布于 2011-11-18 20:35:23
这篇来自维基文章的文章很棒
Sub walkTree(ByVal directory As IO.DirectoryInfo, ByVal pattern As String)
For Each file In directory.GetFiles(pattern)
Console.WriteLine(file.FullName)
Next
For Each subDir In directory.GetDirectories
walkTree(subDir, pattern)
Next
End Sub发布于 2011-11-18 10:33:56
看看MSDN的文章- Recursive Procedures (Visual Basic)。本文将帮助您理解递归的基础知识。
请参阅以下链接:
发布于 2011-11-18 22:11:12
经典名著之一
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Try
Label1.Text = Factorial(20).ToString("n0")
Catch ex As Exception
Debug.WriteLine("error")
End Try
End Sub
Function Factorial(ByVal number As Long) As Long
If number <= 1 Then
Return (1)
Else
Return number * Factorial(number - 1)
End If
End Function 'Factorial在.Net 4.0中,您可以使用BigInteger而不是Long...
https://stackoverflow.com/questions/8176993
复制相似问题