FANDOM


The If statement allows the program to run certain pieces of code based on certain conditions.

Example:

using System;
 
class Test
{
    static void Main() {
        int a = 52; 
        int b = 32;
 
        if (a < b) {
            Console.WriteLine("a is smaller than b.");
        }
        else if (a > b) {
            Console.WriteLine("b is smaller than a.");
        }
        else {
            Console.WriteLine("b is the same size as a.");
        }
    }
}

This code will print "b is smaller than a." to the console. The expressions that can be used can be found here.