The Basic Operators in C#
The basic set of operators supported by the C# language is essentially the same as those supported by C and C++. You can group the available operators into the following categories: arithmetic, relational, logical assignment, and type operators. The conditional operator is in a category by itself.
Arithmetic Operators
Table 4-1 shows the list of available arithmetic operators.
Operator | Usage Example | Description |
---|---|---|
Unary Plus | res = +x; | Returns the value of x. |
Unary Minus | res = -x | Returns zero minus x. |
Addition | res = x + y | Adds x and y. Also used for string concatenation. |
Subtraction | res=x - y | Subtracts y from x. When checked, will throw an OverflowException if the result is outside the range of the result ... |
Get .NET and COM Interoperability Handbook, The now with the O’Reilly learning platform.
O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.