0
0
C Sharp (C#)programming~5 mins

Comparison operators in C Sharp (C#) - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the '==' operator do in C#?
The '==' operator checks if two values are equal. It returns true if they are the same, and false if they are different.
Click to reveal answer
beginner
What is the difference between '==' and '!=' operators?
'==' checks if two values are equal, while '!=' checks if two values are not equal.
Click to reveal answer
beginner
List the four main comparison operators for ordering in C#.
The four main ordering comparison operators are: '<' (less than), '>' (greater than), '<=' (less than or equal to), '>=' (greater than or equal to).
Click to reveal answer
beginner
What type of value do comparison operators return?
Comparison operators return a boolean value: true or false.
Click to reveal answer
intermediate
Can comparison operators be used with strings in C#? If yes, how?
Yes, comparison operators like '==' and '!=' can be used to check if two strings are equal or not. For ordering comparisons, use methods like String.Compare.
Click to reveal answer
What does the expression (5 > 3) evaluate to in C#?
A3
Bfalse
C5
Dtrue
Which operator checks if two values are not equal?
A==
B<=
C!=
D>=
What is the result type of a comparison operation in C#?
Abool
Bstring
Cint
Ddouble
Which operator means 'less than or equal to'?
A<
B<=
C>
D>=
Can you use '>' operator to compare two strings directly in C#?
ANo, you must use String.Compare method
BYes, it compares alphabetically
CYes, but only for string length
DNo, strings cannot be compared
Explain how comparison operators work in C# and give examples of their use.
Think about how you check if two things are equal or one is bigger.
You got /3 concepts.
    Describe the difference between equality and ordering comparison operators in C#.
    Consider checking if things are the same versus which is bigger or smaller.
    You got /3 concepts.