Bird
0
0

Which LINQ method would you use to create a new list containing only the names from a list of Person objects?

easy🧠 Conceptual Q2 of 15
C Sharp (C#) - LINQ Fundamentals
Which LINQ method would you use to create a new list containing only the names from a list of Person objects?
A<code>Select</code>
B<code>Where</code>
C<code>OrderBy</code>
D<code>GroupBy</code>
Step-by-Step Solution
Solution:
  1. Step 1: Identify method for projection

    The Select method transforms each element into a new form, such as extracting a property.
  2. Step 2: Apply to Person objects

    Using Select with p => p.Name creates a list of names.
  3. Final Answer:

    Select -> Option A
  4. Quick Check:

    LINQ Select = Transform [OK]
Quick Trick: Use Select to pick specific properties from objects [OK]
Common Mistakes:
MISTAKES
  • Using Where to extract properties
  • Confusing Select with OrderBy
  • Not returning a value in the lambda

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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