nedcomp hosting homepage

Producten en Diensten
Dedicated servers
Datacenter informatie
Partners, resellers
Helpdesk informatie
Technische docs, tools
Support homepage
ASP componenten
Praktische ASP, ASP.NET
Visual route server
Whois (domein gegevens)
Software documentatie
Whitepapers
Zoeken
Nedcomp / algemeen

Zoeken
 

Copyright © Nedcomp Hosting
Telefoon nr :   +31 184 670111
Fax nummer :   +31 184 631384
E-mailadres :   info@nedcomp.nl
 

C# Programmer's Reference  

+ Operator

The + operator can function as either a unary or a binary operator.

+ expr
expr1 + expr2

Where:

expr
An expression.
expr1
An expression.
expr2
An expression.

Remarks

Unary + operators are predefined for all numeric types. The result of a unary + operation on a numeric type is simply the value of the operand.

Binary + operators are predefined for numeric and string types. For numeric types, + computes the sum of its two operands. When one or both operands are of type string, + concatenates the string representations of the operands.

Delegate types also provide a binary + operator, which performs delegate concatenation.

User-defined types can overload the unary + and binary + operators (see operator).

Example

// cs_operator_plus.cs
using System;
class Test 
{
   public static void Main() 
   {
      Console.WriteLine(+5);        // unary plus
      Console.WriteLine(5 + 5);     // addition
      Console.WriteLine(5 + .5);    // addition
      Console.WriteLine("5" + "5"); // string concatenation
      Console.WriteLine(5.0 + "5"); // string concatenation
      // note automatic conversion from double to string
   }
}

Output

5
10
5.5
55
55

See Also

C# Operators | 7.6.1 Unary plus operator | 7.7.4 Addition operator