If Statement

noun

say it: “IF STAYT-ment” /ɪf ˈsteɪtmənt/

A statement that runs a block of code only when its condition is true.

What is an if statement?

A statement that evaluates a condition before executing some code.

if(age > 21) {
    // add one or more statements here
    price = 19.99;
}

// statements with a single line of code
// can be written like this
if(age > 21) price = 19.99;

In a sentence

  • “An if statement adds free shipping when the total is over $50.”

Level: Novice · More C# terms at this level

Updated

In other subjects