Assignment Operators in c# In Hindi

Assignment Operators in c# In Hindi

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

Assignment Operators in c# In Hindi

List of popular assignment operators in the C# programming language.

OperatorOperator NameAssignment DescriptionillustrationSimilar To
=Assignment symbolIt Used to Assigns the right-hand value to the user define variablep = 7p = 7
+=Add and assignIt used to Adds numeric value and assigns the output valuep += 3p = p + 3
-=Subtract and assignIt used to Subtracts numeric value and assigns the outputp -= 9p = p – 9
*=Multiply and assignIt used to Multiplies numeric value and assigns the final output valuep *= 8p = p * 8
/=Divide and assignIt used to Divides and assigns the numeric division value to outputp /= 5p = p / 5
%=Modulus and assignIt used to Computes remainder value and assigns the value to outputp %= 4p = p % 4
&=Bitwise AND and assignIt used to Performs bitwise AND operator and assigns the output valuep &= 2P =p & 2
|Bitwise OR and assignIt used to Performs Bitwise OR and assign the output valuep |= 7p = p | 7
^=Bitwise XOR and assignIt used to Performs bitwise XOR and assigns the value to outputp ^= 2p = p ^ 2
<<=Left shift and assignIt used to Performs Shifts bits to the left and assigns value to outputp <<= 3p = p << 3
>>=Right shift and assignIt used to Performs Shifts bits to the right and assigns value to output  p >>= 2p = 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

        }

    }

}

Leave a Reply