for is the loop you reach for when you know how many times.
Program.cs
using System;
class Program
{
static void Main()
{
for (int i = 1; i <= 3; i++)
{
Console.WriteLine($"Round {i}");
}
}
}
Output
Round 1 Round 2 Round 3
Three parts, separated by ;:
int i = 1— where the counter startsi <= 3— keep going while this is truei++— what happens after each pass
i++
Shorthand for i = i + 1. There is also i += 2 to step by two.