+= Operator (C# Reference)
The addition assignment operator.
An expression using the
+= operator, such as
x += y
is equivalent to
x = x + y
x is only evaluated once.
For numeric types, the addition operator
+ computes the sum of its operands. If one or both operands is of type string, it concatenates the string representations of its operands. For delegate types, the
+ operator returns a new delegate instance that is combination of its operands.
The following example demonstrates the usage of the
int a = 5; a += 9; Console.WriteLine(a); // Output: 14 string story = "Start. "; story += "End."; Console.WriteLine(story); // Output: Start. End. Action<int> printer = (int s) => Console.WriteLine(s); printer += (int s) => Console.WriteLine(2 * s); printer(3); // Output: // 3 // 6
If a user-defined type overloads the addition operator
+, the addition assignment operator
+= is implicitly overloaded. A user-defined type cannot explicitly overload the addition assignment operator.