C# if statement is used to execute the particular block of code or statements when the defined condition is true. There is a conditional statement upon which given statements execute. If statement checks the given condition and evaluates the result. An if statement in C# can consist of a boolean expression which is followed by one or more statements or codes.
Syntax:
Graphical representation of C# If statement
//ifstatementinc using System; namespace DecisionMaking { public class Program { public static void Main(string[] args) { int x = 76; /* check the condition using if statement */ if (x < 100) { /* if condition is true execute the following */ Console.WriteLine("x is less than 100"); } Console.WriteLine("The Value of x is : {0}", x); Console.ReadLine(); } } }