Mega Code Archive

 
Categories / C# Book / 01 Language Basics
 

0074 if statement

if statement has the following form if (booleanExpression){ statement block; // execute if booleanExpression is true }else{ statement block; // execute if booleanExpression is false } The following code prints out Here is the value if larger than 0. using System; class Program { static void Main(string[] args) { int i = 3; if (i > 0) { Console.WriteLine("Here"); } } } The output: Here