Conteúdo do Curso
C# Basics
C# Basics
Comparison Operators
Before diving into control structures, we need to understand some operators. The first set of operators we will look at are called Comparison Operators.
As expressed by the name, the comparison operators are used for comparing values. Following is a list of all the comparison operators:
Operator | Operation |
== | Equal To |
!= | Not Equal To |
> | Greater Than |
< | Less Than |
>= | Greater Than or Equal To |
<= | Less Than or Equal To |
Using comparison operators we can create logical expressions that return logical values, such as true
or false
. For-example the expression 5 < 1
will output false
as 5
is not greater than 1
.
Note
We can directly put expressions in the Console.Write methods.
main
Following are some more examples of expressions formed using comparison operators:
main
We can also put variables in these expressions:
main
We can store the results of the logical expressions into bool
variables since boolean variables can hold a value of true
or false
:
main
Tudo estava claro?