Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Comparison Operators | Control Structures
course content

Зміст курсу

C# Basics

Comparison OperatorsComparison 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:

OperatorOperation
==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.

cs

main.cs

Following are some more examples of expressions formed using comparison operators:

cs

main.cs

We can also put variables in these expressions:

cs

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:

cs

main.cs

What will be the output of the following code?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 1
course content

Зміст курсу

C# Basics

Comparison OperatorsComparison 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:

OperatorOperation
==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.

cs

main.cs

Following are some more examples of expressions formed using comparison operators:

cs

main.cs

We can also put variables in these expressions:

cs

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:

cs

main.cs

What will be the output of the following code?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 1
some-alt