Assignment Operators in c# In Hindi
C# प्रोग्रामिंग लैंग्वेज में असाइनमेंट ऑपरेटर्स का यूज़ C# प्रोग्राम में डिक्लेअर वेरिएबल्स पैरामीटर डाटा टाइप को एक यूजर डिफाइन न्यूमेरिक, टेक्स्ट, या बूलियन वैल्यू असाइन करने में किया जाता है। C# प्रोग्रामिंग लैंग्वेज में असाइनमेंट ऑपरेटर्स ज्यादातर असाइनमेंट डाटा टाइप वैल्यू को अरिथमेटिक या बिटवाइज़ डाटा टाइप ऑपरेटर ऑपरेशन्स के साथ मर्ज करने में यूज़ होते हैं।

List of popular assignment operators in the C# programming language.
| Operator | Operator Name | Assignment Description | illustration | Similar To |
| = | Assignment symbol | It Used to Assigns the right-hand value to the user define variable | p = 7 | p = 7 |
| += | Add and assign | It used to Adds numeric value and assigns the output value | p += 3 | p = p + 3 |
| -= | Subtract and assign | It used to Subtracts numeric value and assigns the output | p -= 9 | p = p – 9 |
| *= | Multiply and assign | It used to Multiplies numeric value and assigns the final output value | p *= 8 | p = p * 8 |
| /= | Divide and assign | It used to Divides and assigns the numeric division value to output | p /= 5 | p = p / 5 |
| %= | Modulus and assign | It used to Computes remainder value and assigns the value to output | p %= 4 | p = p % 4 |
| &= | Bitwise AND and assign | It used to Performs bitwise AND operator and assigns the output value | p &= 2 | P =p & 2 |
| | | Bitwise OR and assign | It used to Performs Bitwise OR and assign the output value | p |= 7 | p = p | 7 |
| ^= | Bitwise XOR and assign | It used to Performs bitwise XOR and assigns the value to output | p ^= 2 | p = p ^ 2 |
| <<= | Left shift and assign | It used to Performs Shifts bits to the left and assigns value to output | p <<= 3 | p = p << 3 |
| >>= | Right shift and assign | It used to Performs Shifts bits to the right and assigns value to output | p >>= 2 | p = p >> 2 |
Assignment operator examples in C#.
using System;
class AssignmentOperator
{
static void Main()
{
int p = 21;
p += 4; // this is similar to p = p + 4
Console.WriteLine($”p variable value after += operation – {p}”); // Result is – 25
p *= 3; // this is similar to p = p * 3
Console.WriteLine($”p variable value after *= operation – {p}”); // Result is – 75
p %= 2; // this is similar to p = p % 2
Console.WriteLine($”p variable value after %= operation – {p}”); // Result is – 1
p|= 2; // this is similar to p Bitwise OR operation (p = p | 2)
Console.WriteLine($”p variable value after |= operation – {p}”); // Result is – 3
}
}
Bitwise OR and Bitwise XOR examples in C#.
using System;
class BitwiseORandBitwiseXOR
{
static void Main()
{
int p = 9; // equivalent to Binary value – 1001
int q = 7; // equivalent to Binary value – 0111
// here we use Bitwise OR operator
int output = p | q;
Console.WriteLine(output); // Result is – 15
// here we use XOR Assignment operator
p ^= q; // similar as – p = p ^ q
Console.WriteLine(p); // Result is – 14
}
}
Left shift and assign Right shift examples in C#.
using System;
class LeftshiftandassignRightshift
{
static void Main()
{
int q = 8; // Binary equivalent value – 1000
// here we use Left Shift Assignment operator
q <<= 2; // similar as – q = q << 2
Console.WriteLine(q); // Result is – 32
// here we use Right Shift Assignment operator
q >>= 1; // similar as – q = q >> 1
Console.WriteLine(q); // Result is – 16
}
}
Important Notes in the C# Programming Language.
C# Chained Assignment Concept.
C# प्रोग्राम में एक ही यूजर डिफाइन स्टेटमेंट में मल्टीप्ल पैरामीटर वेरिएबल को एक ही वैल्यू के साथ एक जैसी कस्टम वैल्यू असाइन या अलॉट की जा सकती है। और प्रोग्राम में यूजर डिफाइन लॉजिक एक्सप्रेशन के आधार पर इन्हे प्रोसेस किया जा सकता है.
using System;
class ChainedAssignments
{
static void Main()
{
// here we Chained Assignments same value to multiple similar variable
int p, q, r;
p = q = r = 7;
Console.WriteLine(p + q + r); // Result is – 21
}
}
Assignment operators (+=, -=) are used in for loops.
C# प्रोग्राम में आप जरूरत के अनुसार +=, -= असाइनमेंट ऑपरेटर का यूज़ कर फॉर लूप मे स्टार्ट से एन्ड तक लूप वैल्यू को ट्रैवर्स इटरेट या रिपीट कर सकते है.
using System;
class AsignWithForloop
{
static void Main()
{
for (int p = 1; p <= 21; p += 3)
{
Console.WriteLine(p); // Output is – 1, 4 7, 10, 13, 16, 19
}
}
}
