Mega Code Archive

 
Categories / C# Tutorial / Statement
 

Bool values in if statement

using System;    class Example {    public static void Main() {      bool b;        b = false;      Console.WriteLine("b is " + b);      b = true;      Console.WriteLine("b is " + b);        // a bool value can control the if statement      if(b)         Console.WriteLine("This is executed.");        b = false;      if(b)         Console.WriteLine("This is not executed.");      }  } b is False b is True This is executed.