More actions
Updated via bot |
(No difference)
|
Latest revision as of 16:05, 21 October 2025
Use a while loop to repeat a block of code as long as a condition is true.
Write a While Statement in C#
💻 C# Basic Syntax
while (<CONDITION>)
{
// statements to repeat
}
💻 C# Example
int energy = 5;
while (energy > 0)
{
Console.WriteLine("Player runs");
energy--; // decrease energy to eventually end the loop
}
Related Concepts
- Creates: While Statement