Mega Code Archive

 
Categories / C# Book / 01 Language Basics
 

0075 else branch

if statement can have an else branch. The following code prints out There is the value is less than 0. using System; class Program { static void Main(string[] args) { int i = -1; if (i > 0) { Console.WriteLine("Here"); } else { Console.WriteLine("There"); } } } The output: There