Mega Code Archive

 
Categories / C# Book / 01 Language Basics
 

0077 if statement without braces

If if statement only has one statement we can omit the braces{}. using System; class Program { static void Main(string[] args) { int i = 5; if (i > 0) Console.WriteLine("more than 0"); } } The output: more than 0 The good practice is to add the braces all the time.