C# Programming

Relational Operators

C# Programming / Relational Operators

Relational Operators

What Are Relational Operators in C#?

C# relationship operators compare two operands and return a Boolean value (either true or false). These operators are useful for decision-making, loops, and data validation.

List of C# Relational Operators

Following table shows all the relational operators supported by C#. Assume variable A holds 10 and variable B holds 20, then −

OperatorSymbolDescriptionExample
Equal to==Checks if the values of two operands are equal or not, if yes then condition becomes true.(A == B) is not true.
Not equal to!=Checks if the values of two operands are equal or not, if values are not equal then condition becomes true.(A != B) is true.
Greater than>Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.(A > B) is not true.
Less than<Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true.(A < B) is true.
Greater than or equal to>=Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.(A >= B) is not true.
Less than or equal to<=Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true.(A <= B) is true.
Technology
C# Programming
want to connect with us ?
Contact Us