bool type has exactly two possible values: true and false. - CSharp Language Basics

CSharp examples for Language Basics:Data Type

Introduction

The bool type is commonly used to conditionally branch execution flow based with an if statement.

For example:

Demo Code

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");
      }
}

Result


Related Tutorials