Use bool values in if statement in CSharp
Description
The following code shows how to use bool values in if statement.
Example
//w ww. ja v a2 s .com
using System;
public class MainClass {
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.");
}
}
The code above generates the following result.