← Back to C# Course | Chapter 2: Variables & Types | Lesson 3 of 7

The bool Type

In this page:

  1. The bool Type

The bool Type

A bool holds either true or false and is the result of every comparison and logical expression. Booleans drive if statements, loops, and conditional logic throughout C#. Unlike some languages, C# never implicitly converts numbers to booleans.

Note: Comparison operators like ==, >, and < always evaluate to a bool.

Example: The bool Type

markup
using System;

class Program
{
    static void Main(string[] args)
    {
        bool isActive = true;
        bool hasPermission = false;
        bool isAdult = 20 >= 18;

        Console.WriteLine(isActive);
        Console.WriteLine(hasPermission);
        Console.WriteLine(isAdult);
    }
}
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.