C# Programming

Assignment Operators

C# Programming / Assignment Operators

Assignment Operators

What Are Assignment Operators in C#?

C# assignment operators assign values to variables along with the assignment; in some cases, these operators perform mathematical operators.

List of C# Assignment Operators

There are following assignment operators supported by C# −

OperatorSymbolDescriptionExample
Simple Assignment=Simple assignment operator, Assigns values from right side operands to left side operandC = A + B assigns value of A + B into C
Add and Assign+=Add AND assignment operator, It adds right operand to the left operand and assign the result to left operandC += A is equivalent to C = C + A
Subtract and Assign-=Subtract AND assignment operator, It subtracts right operand from the left operand and assign the result to left operandC -= A is equivalent to C = C - A
Multiply and Assign*=Multiply AND assignment operator, It multiplies right operand with the left operand and assign the result to left operandC *= A is equivalent to C = C * A
Divide and Assign/=Divide AND assignment operator, It divides left operand with the right operand and assign the result to left operandC /= A is equivalent to C = C / A
Modulus and Assign%=Modulus AND assignment operator, It takes modulus using two operands and assign the result to left operandC %= A is equivalent to C = C % A
Left Shift and Assign<<=Left shift AND assignment operatorC <<= 2 is same as C = C << 2
Right Shift and Assign>>=Right shift AND assignment operatorC >>= 2 is same as C = C >> 2
Bitwise AND and Assign&=Bitwise AND assignment operatorC &= 2 is same as C = C & 2
Bitwise XOR and Assign^=bitwise exclusive OR and assignment operatorC ^= 2 is same as C = C ^ 2
Bitwise OR and Assign|=bitwise inclusive OR and assignment operatorC |= 2 is same as C = C | 2
Technology
C# Programming
want to connect with us ?
Contact Us