Bird
0
0

Identify the error in this LINQ query:

medium📝 Debug Q14 of 15
C Sharp (C#) - LINQ Fundamentals
Identify the error in this LINQ query:
var result = from x in numbers where x => 5 select x;
AMissing semicolon at the end
BThe '=>' operator is incorrect for comparison
C'from' keyword is misspelled
D'select' keyword should be 'choose'
Step-by-Step Solution
Solution:
  1. Step 1: Check the where clause syntax

    The where clause uses 'x => 5' which is incorrect for comparison; it should be 'x >= 5'.
  2. Step 2: Verify other parts of the query

    The semicolon is present, 'from' and 'select' keywords are correct.
  3. Final Answer:

    The '=>' operator is incorrect for comparison -> Option B
  4. Quick Check:

    Use '>=' for comparison, not '=>' [OK]
Quick Trick: Remember: '>=' is comparison, '=>' is lambda arrow [OK]
Common Mistakes:
MISTAKES
  • Confusing lambda '=>' with comparison '>='
  • Thinking 'choose' replaces 'select'
  • Ignoring syntax errors in where clause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Sharp (C#) Quizzes