Unary Operators

As previously stated, unary operators affect a single expression. In many instances, the unary operators enable operations with simpler syntax than a comparable binary operation. The unary operators include + (plus), - (minus), ++ (increment), -- (decrement), ! (logical negation), and ~ (bitwise complement).

Note

Mathematical operations on floating-point types are performed according to IEEE 754 arithmetic.

The Plus Operator

The plus operator (+) has no effect on the expression it's used with. Why would a language have an operator that has no effect? For consistency. Most C# operators have a logical complement. Since there is a minus operator, its logical complement is the plus operator. The + operator is available to explicitly ...

Get C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.