Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

+: practical reference

+: practical reference: The + operator adds numbers, concatenates strings, or invokes a user-defined overload.

Version: C# language; verified against C# 14 reference

Syntax

left + right

The + operator adds numbers, concatenates strings, or invokes a user-defined overload.

Use it only when the operand types and intended meaning are explicit.

Numeric promotions, null string concatenation, and overloads can alter the result.

Integral overflow follows checked context; floating point can produce NaN or infinity.

The complete program actually uses +; its exact expected stdout is 5.

Examples

using System;
using System.Linq;
using System.Threading.Tasks;

Console.WriteLine(2 + 3);

Result

5

The complete program actually uses `+`; its exact expected stdout is `5`.

Sources