Bird
0
0

Given the class Person { public string Name; public int Age; } and list people with three persons: Alice(30), Bob(25), and Carol(35), what does this LINQ query return?

medium📝 Predict Output Q13 of 15
C Sharp (C#) - LINQ Fundamentals
Given the class Person { public string Name; public int Age; } and list people with three persons: Alice(30), Bob(25), and Carol(35), what does this LINQ query return?
var result = people.Where(p => p.Age > 28).Select(p => p.Name).ToList();
A["Alice", "Carol"]
B["Bob"]
C["Alice", "Bob", "Carol"]
DEmpty list
Step-by-Step Solution
Solution:
  1. Step 1: Filter people older than 28

    Alice is 30 (yes), Bob is 25 (no), Carol is 35 (yes).
  2. Step 2: Select their names

    Names selected are "Alice" and "Carol".
  3. Final Answer:

    ["Alice", "Carol"] -> Option A
  4. Quick Check:

    Age > 28 filters Alice and Carol [OK]
Quick Trick: Filter first, then select property [OK]
Common Mistakes:
MISTAKES
  • Including Bob who is younger
  • Selecting whole object instead of names
  • Confusing > with <

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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