Chapter 23. RECURSION FUNDAMENTALS

You will learn about the following in this chapter:

  • Recursive methods and recursion

  • The ability of C# to support pending method instances of the same method, and why this is an imperative ability when implementing recursive methods

  • The key ingredients of a successful recursive method

  • The fundamental reasons why recursion works

  • Recursion versus iteration

  • Binary search implemented using recursion instead of iteration

In this book, you have seen many examples of methods calling other methods. For example MethodA might, from within its method body, call MethodB to help MethodA accomplish a certain task. C# also allows a method to call itself. If MethodA's body contains a call to MethodA, MethodA is said to call itself. ...

Get C# Primer Plus 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.