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

bool Type क्या है

एक bool एक light switch है जो सिर्फ on या off, true या false हो सकता है। Programs इसका उपयोग 'क्या दरवाज़ा खुला है?' जैसे हां-या-नहीं वाले सवालों के जवाब के लिए करते हैं।

In this page:

  1. The bool Type
Syntax
csharp
bool variableName = true;
bool result = value1 >= value2;

The bool Type

एक bool या तो true या false रखता है और हर comparison और logical expression का result होता है। Booleans पूरे C# में if statements, loops, और conditional logic चलाते हैं। कुछ languages के विपरीत, C# कभी numbers को booleans में implicitly convert नहीं करता।

Note: ==, >, और < जैसे comparison operators हमेशा एक bool evaluate होते हैं।

उदाहरण: 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);
    }
}
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. x == true या बस if (x) के बजाय if (x = true) लिखना।
  2. यह उम्मीद करना कि numbers booleans की तरह काम करें, जबकि C# 0 या 1 को false या true नहीं मानता।
  3. true के बजाय True या TRUE लिखना, क्योंकि C# keywords lowercase हैं।
🔒

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.