Bird
Raised Fist0

Find the error in this LINQ query:

medium📝 Debug Q7 of Q15
C Sharp (C#) - LINQ Fundamentals
Find the error in this LINQ query:
var result = from n in numbers select n where n > 5;
AMissing 'in' keyword after 'n'
BThe 'where' clause must come before 'select'
CCannot use 'select' in LINQ query
DMissing semicolon after 'numbers'
Step-by-Step Solution
Solution:
  1. Step 1: Understand the order of clauses in LINQ

    The 'where' clause must appear before 'select' in query syntax.
  2. Step 2: Identify the incorrect order in the query

    The query places 'select' before 'where', which is invalid.
  3. Final Answer:

    The error is that 'where' must come before 'select'. -> Option B
  4. Quick Check:

    Clause order: from -> where -> select [OK]
Quick Trick: Put 'where' before 'select' in LINQ queries [OK]
Common Mistakes:
MISTAKES
  • Placing 'select' before 'where'
  • Omitting 'in' keyword
  • Syntax errors with semicolons

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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