csharp while function code example Example: C# while int n = 0; while (n < 5) { Console.WriteLine(n); n++; }