Working with Recursion

Recursion refers to procedures calling themselves. An example of a recursive function was introduced in Listing 5.1; the Factorial function was implemented as a recursive function. Each time Factorial was called, one step of the equation was solved.

Recursive procedures call themselves before exiting until all recursions are complete. Using recursion as shown in the Factorial function can be problematic because this function will be called recursively n - 1 times where n is the initial value of the Value parameter. If Value were very large in the call to Factorial, you could end up running out of memory before all the recursive calls to Factorial could be handled.

Visual Basic .NET allows you to define very large procedural ...

Get Visual Basic® .NET Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.