Pending Method Instances of the Same Method

While MethodC was being executed in the program of Listing 23.1, each of the methods Main, MethodA, and MethodB had exactly one associated pending method instance. It also is possible for one single method to have many associated pending method instances in C#. This ability is one of the fundamental requirements for writing recursive methods in a particular computer language. To demonstrate this ability, let's look at Listing 23.2 that generates four pending method instances similar to those in Listing 23.1, but this time the pending method instances (apart from Main) are all of the same method. It is our aim with the single method in Listing 23.2 to get as close as possible to the functionality of ...

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.