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#?
✗ Incorrect
5 is greater than 3, so (5 > 3) evaluates to true.
Which operator checks if two values are not equal?
✗ Incorrect
'!=' checks if two values are not equal.
What is the result type of a comparison operation in C#?
✗ Incorrect
Comparison operators return a boolean (bool) value: true or false.
Which operator means 'less than or equal to'?
✗ Incorrect
'<=' means less than or equal to.
Can you use '>' operator to compare two strings directly in C#?
✗ Incorrect
You cannot use '>' directly on strings; use String.Compare for ordering comparisons.
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.