In C#, operators are symbols that represent the operation that the programme must execute on the operands. They can, for example, be used to evaluate a variable or to execute an action on a variable in order to create a valid expression.
Arithmetic operators, Relational operators, Assignment operators, Logical operators, Unary operators, and more operators are available in C#. In this lesson, we'll go over some of the most essential operators and how to use them.
The table below lists all of the relational operations provided by the C programming language. Assume variable A has a value of 10 and variable B has a value of 20.
Operator | Description | Example |
---|---|---|
== | Checks whether two operands have the same value. If the answer is yes, the condition is fulfilled. | (A == B) is not true. |
!= | Checks whether two operands have the same value. The condition becomes true if the values are not equal. | (A != B) is true. |
> | If the left operand's value is greater than the right operand's value, the condition is true. The condition becomes true if the answer is yes. | (A > B) is not true. |
< | Checks whether the left operand's value is smaller than the right operand's value. If the answer is yes, the condition is fulfilled. | (A < B) is true. |
<= | Checks whether the left operand's value is greater than or equal to the right operand's value. If the answer is yes, the condition is fulfilled. | (A <= B) is true |
>= | Checks whether the left operand's value is less than or equal to the right operand's value. If the answer is yes, the condition is fulfilled. | (A <= B) is true. |
|