#168 – Use if Statement to Conditionally Execute a Block of Code

You can use the if statement in C# to check the value of a boolean expression and execute a block of code only if the expression is true.

            if (userAge >= 50)
                Console.WriteLine("Hey, you should consider joining AARP!");

If the value of the userAge variable is greater than or equal to 50, the block of code will be executed.  If the age is less than 50, the block will not be executed and the program will continue with the first statement after the block of code.