C# assignment operator and analysis

Article Directory

  • Blogger writing is not easy, kids need your encouragement
  • Thousands of waters and thousands of mountains are always in love, so please click a like first.

The assignment operator evaluates the operating expression on the right side of the operator and uses the value to set the variable operating expression on the left side of the operator. Assignment operators mainly include simple assignment and compound assignment operators; the object types that can be placed on the left side of the assignment operator are variables, attributes, indexes, and events. If the types of operands on both sides of the assignment operator are inconsistent, you need to perform type conversion first, and then assign.

Operator Description
= Assign the value after "=" to the variable before "="
+= Add assignment x+=y is equivalent to x=x+y
-= Subtraction assignment x-=y is equivalent to x=xy
*= Multiplication assignment x*=y is equivalent to x=x*y
/= Division assignment x/=y is equivalent to x=x/y
%= Modulus assignment x%=y is equivalent to x=x%y
&= Bit and assignment x&=y is equivalent to x=x&y
l= Bitwise OR assignment xl=y is equivalent to x=xly
>>= Right shift assignment x>>=y is equivalent to x=x>>y
<<= Left shift assignment x<<=y is equivalent to x=x<<y
^= XOR assignment x^=y is equivalent to x=x^y
  • About the blogger:
  • Industrial automation upper computer software engineer, machine vision algorithm engineer, motion control algorithm engineer. Currently working in the intelligent manufacturing automation industry. Blogger's mailbox: [email protected]
  • Help me like it. Haha.

Guess you like

Origin blog.csdn.net/cashmood/article/details/109159107