if statement usage - CSharp Language Basics

CSharp examples for Language Basics:if

Description

if statement usage

Demo Code

using System;//  www  .  j a va 2 s  .c o m
public class Statements {
   public static void Main( ) {
      bool condition1 = true;
      bool condition2 = false;
      if( condition1 )
         Console.WriteLine("You should see this");
      if( condition2 )
         Console.WriteLine("You should not see this");

      if( condition1 && !condition2 )
         Console.WriteLine("Will you see this?");

      if( condition1 ) {
         Console.WriteLine("Statement 1");
         Console.WriteLine("Statement 2");
      }
   }
}

Result


Related Tutorials