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.

Table 4-1. C# Arithmetic operators
OperatorUsage ExampleDescription
Unary Plusres = +x;Returns the value of x.
Unary Minusres = -xReturns zero minus x.
Additionres = x + yAdds x and y. Also used for string concatenation.
Subtractionres=x - ySubtracts 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 books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.