
If / else (Ch. 6)
C# Conditional Statements and Control Flow Example: If-Else Statement Here is an example that demonstrates the use of if, else if, and else statements to check the value of a variable and print corresponding messages. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 int number = 10; if (number > 10) { Console.WriteLine("The number is greater than 10"); } else if (number == 10) { Console.WriteLine("The number is equal to 10"); } else { Console.WriteLine("The number is less than 10"); } Explanation If Statement ...