CSharp examples for Language Basics:if
An if statement executes a statement if a bool expression is true. For example:
using System;//w ww.ja v a 2 s .c o m class Test { static void Main(){ if (5 < 2 * 3) Console.WriteLine ("true"); // true } }
The statement can be a code block:
using System;//w w w .j a v a2 s . co m class Test { static void Main(){ if (5 < 2 * 3) { Console.WriteLine ("true"); Console.WriteLine ("Let's move on!"); } } }