IF statement
- C# if statement will execute
a block of code if the given condition is true.
Syntax
| 
if(statement is TRUE) 
EXECUTE this line of code 
Syntax Example 1 : 
if(expression) 
{ 
    statements; 
} 
else 
{ 
    statements; 
} | 
Example 1
| 
class Program 
{ 
  static void Main(string[] args) 
  { 
    int age = 0; 
    Console.WriteLine(“please enter your age
  to find out your eligibility for voting”) ; 
    age =
  Convert.ToInt32(Console.ReadLine()); 
    if (age < 18) 
    { 
      Console.WriteLine(“You are not eligible
  for voting”) ; 
    } 
    else 
    { 
      Console.WriteLine(“You are eligible for voting”) ; 
    } 
    Console.Read(); 
  } 
} | 
 
