bool Type क्या है
एक bool एक light switch है जो सिर्फ on या off, true या false हो सकता है। Programs इसका उपयोग 'क्या दरवाज़ा खुला है?' जैसे हां-या-नहीं वाले सवालों के जवाब के लिए करते हैं।
In this page:
Syntax
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
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);
}
}
Login to try C/C++/Java/PHP code in the editor
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. #}
आम गलतियां
x == trueया बसif (x)के बजायif (x = true)लिखना।- यह उम्मीद करना कि numbers booleans की तरह काम करें, जबकि C# 0 या 1 को
falseयाtrueनहीं मानता। trueके बजायTrueयाTRUEलिखना, क्योंकि C# keywords lowercase हैं।
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: