do-while Loop

noun

say it: “DOO WYLE loop” /duː waɪl luːp/

A loop that runs its block once first and then repeats while its condition stays true.

What is do-while Loop in C#?

do-while Loop — A loop that runs its body once before checking whether to repeat.

class Counter
{
    int CountToThree()
    {
        int number = 0;

        while (number < 3)
        {
            number++;
        }

        return number;
    }
}

In a sentence

  • “A do-while loop shows the menu once before checking whether the user wants to quit.”

Level: Apprentice · More C# terms at this level

Updated

In other subjects