In the C# programming language, the IF statement is a logical condition check. Its function is to check if a condition is true, and if so, run some specified code.
The ELSE-IF statement can appear after an If statement, and specifies a second condition to check for once the first has been evaluated as False.
The code inside an Else-If statement runs ONLY IF the precedingIf statement is false.
The ELSE statement can be attached to the end of an IF/ELSE-IF chain. Like the name implies, if all IF and ELSE-IF conditions are False, the code contained in ELSE will run.
The use cases for any type of IF statement are numerous, and it is usually the go-to method to run code based on conditions.
There is also a way to simplify the writing of IF statements even more. It is called a Ternary Operator, and is written like so: