C# Language Binary operators with assignment


Example

C# has several operators that can be combined with an = sign to evaluate the result of the operator and then assign the result to the original variable.

Example:

x += y

is the same as

x = x + y

Assignment operators:

  • +=
  • -=
  • *=
  • /=
  • %=
  • &=
  • |=
  • ^=
  • <<=
  • >>=