Operators and Handling Errors
In this chapter
- Apply arithmetic operators to values
- Learn other operators including comparison, logical and binary operators
- Describe syntax errors, logic errors, and runtime errors
- Learn how to cast one data type to another​
At its heart the computer is really just a very big calculator, taking in data and processing that data using a variety of different operators. These operators include:
- Arithmetic: plus, minus, multiply etc.
- Assignment: assigning values to variables
- Comparison: comparing two literal values or variables
- Logical: operators that work on Boolean data types
- Binary: to carry out operations on binary digits (bits)
- Type conversion: to convert from one data type to another
There is an order or precedence with these operators. Just as in Maths multiplication takes precedence over addition but when using complex expressions it is advisable to use brackets to force precedence: brackets, division and multiplication, addition and subtraction.
Here we will review each of these operators categories and how they are used with C#.