Bird
0
0

Which of the following best describes the return type of GroupBy in C#?

easy🧠 Conceptual Q2 of 15
C Sharp (C#) - LINQ Fundamentals
Which of the following best describes the return type of GroupBy in C#?
AA List of keys only
BA single grouped collection without keys
CAn IEnumerable of groups, each with a key and a collection of elements
DA Dictionary with keys and single elements
Step-by-Step Solution
Solution:
  1. Step 1: Recall GroupBy return type

    The GroupBy method returns an IEnumerable<IGrouping<TKey, TElement>>, where each group has a key and a collection of elements.
  2. Step 2: Eliminate incorrect options

    It is not just keys, nor a single collection, nor a dictionary with single elements.
  3. Final Answer:

    An IEnumerable of groups, each with a key and a collection of elements -> Option C
  4. Quick Check:

    GroupBy return type = IEnumerable of groups [OK]
Quick Trick: GroupBy returns groups with keys and collections, not just keys [OK]
Common Mistakes:
MISTAKES
  • Thinking it returns a dictionary
  • Expecting a flat list
  • Confusing keys with elements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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