As a beginner, I am pretty confused about the manner in which the following C# recursion can run.
class program
{
public void Count(int inVal)
{
if(inVal == 0)
return;
Count(inVal - 1);
Console.WriteLine("{0}",inVal);
}
static void Main()
{
Program pr = new program;
pr.Count(3);
}
}
From my perspectives, the 'program' should stop when 'intVal' reaches 0 because the flow cannot pass through 'if(intVal == 0) return;'. How can it print out '1 2 3' sequentially? I would appreciate it if anyone knows the principles among them.