Зміст курсу
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.cs
Following are some more examples of expressions formed using comparison operators:
main.cs
We can also put variables in these expressions:
main.cs
We can store the results of the logical expressions into bool
variables since boolean variables can hold a value of true
or false
:
main.cs
Все було зрозуміло?
Зміст курсу
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.cs
Following are some more examples of expressions formed using comparison operators:
main.cs
We can also put variables in these expressions:
main.cs
We can store the results of the logical expressions into bool
variables since boolean variables can hold a value of true
or false
:
main.cs
Все було зрозуміло?