+ Operator (C# Reference)

The + operator is supported in two forms: a unary plus operator or a binary addition operator.

Unary plus operator

The unary + operator returns the value of its operand. It's supported by all numeric types.

Numeric addition

For numeric types, the + operator computes the sum of its operands:

Console.WriteLine(5 + 4);       // output: 9
Console.WriteLine(5 + 4.3);     // output: 9.3
Console.WriteLine(5.1m + 4.2m); // output: 9.3

For more information about arithmetic operators, see Arithmetic operators.

String concatenation

When one or both operands are of type string, the + operator concatenates the string representations of its operands:

Console.WriteLine("Forgot " + " white space");
Console.WriteLine("Probably the oldest constant: " + Math.PI);
// Output:
// Forgot white space
// Probably the oldest constant: 3.14159265358979

Starting with C# 6, string interpolation provides a more convenient way to format strings:

Console.WriteLine($"Probably the oldest constant: {Math.PI:F2}");
// Output:
// Probably the oldest constant: 3.14

Delegate combination

For delegate types, the + operator returns a new delegate instance that, when invoked, invokes the first operand and then invokes the second operand. If any of the operands is null, the + operator returns the value of another operand (which also might be null). The following example shows how delegates can be combined with the + operator:

Action<int> printDouble = (int s) => Console.WriteLine(2 * s);
Action<int> printTriple = (int s) => Console.WriteLine(3 * s);
Action<int> combined = printDouble + printTriple;
// Output:
// 10
// 15

For more information about delegate types, see Delegates.

Operator overloadability

User-defined types can overload the unary and binary + operators. When a binary + operator is overloaded, the addition assignment operator += is also implicitly overloaded.

C# language specification

For more information, see the Unary plus operator and Addition operator sections of the C# language specification.

See also