Here\'s my code
using System;
public class Program
{
public static void Method(int flowerInVase)
{
if (flowerInVase > 0)
{
The compiler uses writeline only when it's done doing recursion.
It does that because you told it to do that. In your code, first perform the recursion (call Method()
) and only when that finishes, you write the number.
If you want to write the number first, before performing recursion, you need to switch of statements in your code:
public static void Method(int flowerInVase)
{
if (flowerInVase > 0)
{
Console.WriteLine(flowerInVase);
Method(flowerInVase - 1);
}
}