There are a few categories of builtin operations you can do: mathematical operations, bitwise operations, logical operations, conditional operations, and assignment operations.
Note that all binary operations here require both operands to be of the same type, but we'll see in Type of Numeric Constants that the two constants
82.9 don't necessarily have different types.
The mathematical operations should be fairly obvious:
* are all valid binary operators to be used on two numeric types.
The modulo operator,
%, is only valid on integers.
Bitwise operations are only valid on integers, and include:
<<: Shift left
>>: Shift right
|: Bitwise OR
&: Bitwise AND
^: Bitwise XOR
~: Bitwise NOT
Logical operations can only be used on boolean expressions, and there is only
&& for logical NOT, logical OR, and logical AND respectively. The binary logical operations are short-circuiting.
The following conditional operations are:
<: Less than
>: Greater than
<=: Less than or equal to
>=: Greater than or equal to
==: Equal to
!=: Not equal to
The less than/greater than family of conditional operations are only valid on numeric values, while the equal to and not equal to can be used on values of any of the builtin types.
All of the conditional operations can be used on new types, since the conditional operations are defined for the builtin
Ordered interface types. See Interfaces, Extensions and Classes for more information on how to do this.
All of the non-conditional operations here can be combined with a single equal sign to become an assignment operation. For example,
a += b is equivalent to
a = a + b.