In this example, we declare two boolean variables: isRaining and hasUmbrella. We then use them to make a decision about what to print to the console. If it's raining and the person doesn't have an umbrella, we warn them that they're going to get wet. If it's raining and they do have an umbrella, we tell them that they're prepared. If it's not raining, we encourage them to enjoy the sunshine.
The && operator is used to represent the logical AND operation, and the ! operator is used to represent logical NOT operation.
Booleans in C-Sharp in Hindi
Booleans C# mein ek data type hote hain jo ek logical value ko represent karte hain, jismein sirf true ya false ke alawa koi aur value nahi hoti. Ye programming mein decisions lene ke liye aur code ko control karne ke liye bahut upyogi hote hain.
Yahan ek C# example hai jismein booleans ka use kiya gaya hai:
Is example mein humne do boolean variables declare kiye hain: isRaining aur hasUmbrella. Fir hum inka use console par kuch print karne ke decision lene ke liye kiya hai. Agar barish ho rahi hai aur insaan ke paas umbrella nahi hai, to hum unhe bataate hain ki unhe bheegna padega. Agar barish ho rahi hai aur unke paas umbrella hai, to hum unhe batate hain ki woh barish ke liye taiyaar hain. Agar barish nahi ho rahi hai, to hum unhe encourage karte hain ki woh maje karein.
&& operator logical AND operation ko represent karne ke liye istemal hota hai, aur ! operator logical NOT operation ko represent karne ke liye istemal hota hai.
About Author
Brijesh Kumar
Database Developer
I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL
Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall
and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com