+= Operator (C# Reference)

The addition assignment operator.

An expression using the += operator, such as

x += y

is equivalent to

x = x + y

except that 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.

You also use the += operator to specify an event handler method when you subscribe to an event. For more information, see How to: Subscribe to and Unsubscribe from Events.

The following example demonstrates the usage of the += operator:

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

Operator overloadability

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.

C# language specification

For more information, see the Compound assignment and Event assignment sections of the C# language specification.

See also