Logical Operators in c# In Hindi
C# प्रोग्रामिंग लैंग्वेज में लॉजिकल ऑपरेटर्स का यूज़ यूजर डिफाइन डाटा टाइप वेरिएबल वैल्यू पर बूलियन लॉजिकल एक्सप्रेशन ऑपरेशन को परफॉर्म करने और दी गई यूजर डिफाइन एंड लॉजिकल कंडीशन के आधार पर true या false वैल्यू के रूप में आउटपुट रिटर्न करने में किया जाता है। C# प्रोग्राम में कॉम्प्लेक्स कंडीशनल एक्सप्रेशन स्टेटमेंट क्रिएट करने के लिए लॉजिकल ऑपरेटर एसेंशियल हैं। सामान्य C# प्रोग्राम में लॉजिकल ऑपरेटर्स में आप &&, !, ^, आदि प्रोग्राम ऑपरेशन लॉजिक को परफॉर्म कर सकते है.

Details of Logical Operators in the C# Programming Language.
| Operator | Operator Name | Logical operator Description | Example | Output |
| && | Logical AND operator | It Returns true output, when both user define program conditions are true | p > 7 && q < 17 | Result is true |
| || | Logical OR operator | It Returns true when one user define program conditions is true | p < 7 || q > 13 | Result is true |
| ! | Logical NOT operator | It Reverses the Boolean value operation given in program | !(p > 9) | Result is false |
| ^ | Logical XOR operator | It Returns true output, when exactly one user define program condition is true | a > 3 ^ b < 2 | Result is true |
Logical AND (&&) Operator in C#.
C# प्रोग्रामिंग लैंग्वेज में एंड लॉजिकल ऑपरेटर का यूज़ दो वेरिएबल पैरामीटर वैल्यू चेक करने में किया जाता है, C# प्रोग्राम में लॉजिकल एंड ऑपरेटर तभी आउटपुट वैल्यू को true रिटर्न करता है. जब एक ही समय प्रोग्राम में दी गई दोनों एंड लॉजिक कंडीशन एक्सप्रेशन true डिफाइन हों।
Logical AND (&&) operator example in C#.
using System;
class LogicalAndOP
{
static void Main(string[] args)
{
int p = 7, q = 27;
if (p > 4 && q > 21)
{
Console.WriteLine(“Both user define && operator conditions is true.”); // This will execute as true
}
Console.ReadLine(); // this function Keeps the console window open for output
}
}
Logical OR (||) operator in C#.
C# प्रोग्रामिंग लैंग्वेज में लॉजिकल और ऑपरेटर दो यूजर डिफाइन प्रोग्राम डाटा टाइप पैरामीटर वेरिएबल वैल्यू में यह तभी true आउटपुट वैल्यू रिटर्न करता है, जब दिए गए लॉजिकल और ऑपरेटर में कम से कम एक यूजर डिफाइन प्रोग्राम कंडीशन एक्सप्रेशन true नेचर डिफाइन हो।
Logical OR (||) operator example in C#.
using System;
class OrLogicalOP
{
static void Main(string[] args)
{
int p = 4, q = 9;
if (p < 6 || q > 13)
{
Console.WriteLine(“in both variable At least one OR condition must be true.”); // This will execute or logical condition statement
}
Console.ReadLine(); // here it will Keeps the console window open for operation
}
}
Logical NOT (!) operator in C#.
लॉजिकल नॉट C# प्रोग्राम में बूलियन वैल्यू को रिवर्स कर देता है। जैसे आउटपुट ट्रू है, तो उसे फाल्स कर देता है. इसकी प्रकार यदि आउटपुट फाल्स है, तो यह उसे ट्रू कर देता है.
Example of the Logical NOT (!) operator.
using System;
class LogicalNotOP
{
static void Main(string[] args)
{
bool chekValue = false;
if (!chekValue)
{
Console.WriteLine(“the check value is tested.”); // This will logical not operator statement execute
}
Console.ReadLine(); // here it Keeps the console window open for reading
}
}
Logical XOR (^) operator in C#.
C# प्रोग्राम में यूजर डिफाइन लॉजिकल एक्सप्रेशन कंडीशन में यदि यूजर एडेड सिर्फ़ एक प्रोग्राम लॉजिकल कंडीशन ट्रू है, लेकिन उसी समय में दोनों यूजर डिफाइन कंडीशन लॉजिक नहीं है. तो यह आउटपुट के रूप में true रिजल्ट डिस्प्ले करता है।
Logical XOR (^) operator example.
using System;
class LogicalXorOP
{
static void Main(string[] args)
{
bool logic1 = true;
bool logic2 = false;
if (logic1 ^ logic2)
{
Console.WriteLine(“here Exactly one XOR logical condition expression must be true.”); // here This statement will execute
}
Console.ReadLine(); // here it Keeps the console window open for reading
}
}
C# Logical Operators Important Notes.
- C# प्रोग्राम में लॉजिकल ऑपरेटर में शॉर्ट-सर्किटिंग (&& और ||) कांसेप्ट.
- && – यदि C# प्रोग्राम में पहली कंडीशन फाल्स है, तो यह मौजूदा प्रोग्राम इवैल्यूएट करना बंद कर देता है।
- || – यदि C# प्रोग्राम में पहली कंडीशन ट्रू है, तो यह मौजूदा प्रोग्राम इवैल्यूएट करना बंद कर देता है।
ShortCircuiting C# Example.
using System;
class ShortCircuiting
{
static void Main(string[] args)
{
int p = 11;
if (p < 17 && TestExpressinReturnsFalse()) // here this will TestExpressinReturnsFalse() run
{
Console.WriteLine(“it dont execute in program”);
}
Console.ReadLine(); // here it Keeps the console window open for reading
}
static bool TestExpressinReturnsFalse()
{
Console.WriteLine(“TestExpressinReturnsFalse() is called now”);
return false;
}
}
Combining logical operators in a C# program.
C# प्रोग्रामर प्रोग्राम में कॉम्प्लेक्स लॉजिकल कंडीशन एक्सप्रेशन को क्रिएट करने के लिए कई लॉजिकल ऑपरेटर्स को आपस में ग्रुप कर सकते हैं।
Combining logical operators C# Example.
using System;
class LogicalAndOROP
{
static void Main(string[] args)
{
int salary = 999;
bool isTested = (salary > 499 && salary < 1999) || (salary == 2999);
Console.WriteLine(isTested); // Result – true
Console.ReadLine(); // here it Keeps the console window open for reading
}
}
