Skip to content

if Statement

The if statement executes a block if the condition is true.

int temperature = 25;
if (temperature > 20)
{
Console.WriteLine("It's warm outside.");
}
Terminal window
dotnet run
Terminal window
It's warm outside.