CSharp examples for Language Basics:Data Type
The bool type is commonly used to conditionally branch execution flow based with an if statement.
For example:
using System;// www . j av a 2 s. com class Test { static void Main(){ bool simpleVar = false; if (simpleVar) Console.WriteLine ("This will not print"); int x = 5000; bool lessThanAMile = x < 5280; if (lessThanAMile) Console.WriteLine ("This will print"); } }