Bird
Raised Fist0

What is wrong with this LINQ query?

medium📝 Debug Q7 of Q15
C Sharp (C#) - LINQ Fundamentals
What is wrong with this LINQ query?
var result = people.Select(p => p.Name).Where(name => name.Length > 3);
AThe order of <code>Select</code> and <code>Where</code> is reversed
BThe lambda parameter name is invalid
CThe query is correct and will work as expected
DYou cannot use <code>Where</code> after <code>Select</code>
Step-by-Step Solution
Solution:
  1. Step 1: Understand method chaining

    Select projects to names (strings), then Where filters those names by length.
  2. Step 2: Confirm correctness

    This chaining is valid and will return names longer than 3 characters.
  3. Final Answer:

    The query is correct and will work as expected -> Option C
  4. Quick Check:

    Select then Where on projected data is valid [OK]
Quick Trick: You can filter after selecting properties if types match [OK]
Common Mistakes:
MISTAKES
  • Thinking order must be reversed
  • Confusing lambda parameter names
  • Assuming Where only works on original objects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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