Skip to content

while Loop

The while loop repeats as long as the condition is true.

int counter = 0;
while (counter < 3)
{
Console.WriteLine($"Count: {counter}");
counter++;
}
Terminal window
dotnet run
Terminal window
Count: 0
Count: 1
Count: 2