Operators in C#
5 Operators in C# can be separated in several different categories:
Category Operators
arithmetic -, +, *, /, %, ++, --
logical &&, ||, !, ^
binary &, |, ^, ~, <<, >>
comparison ==,!=, >, <, >=, <=
assignment =, +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=
string concatenation +
type conversion (type), as, is, typeof, sizeof
other ., new, (), [], ?:, ??
5
A bitwise operator- is an operator that acts on the binary representation of numeric types.
Compound assignment operators- They help to reduce the volume of the code by typing two operations
together with an operator: operation and assignment.
0
Conditional operator ?- uses the Boolean value of an expression to determine which of two other expressions
must be calculated and returned as a result. The operator works on three operands and that is why it is called
ternary operator.
5 Other Operators
Access operator "." (dot)- is used to access the member fields or methods of a class or object.
Square brackets [] - are used to access elements of an array by index, they are the so-called indexer.
0 Indexers are also used for accessing characters in a string.
Brackets () are used to override the priority of execution of expressions and operators.
Explicit type conversion- is used whenever there is a possibility of data loss. When converting floating point
0 type to integer type there is always a loss of data coming from the elimination of the fractional part and an
explicit conversion is obligatory (e.g. double to long).
Expressions - are sequences of operators, literals and variables that are calculated to a value of some
type (number, string, object or other type).
5