Bird
Raised Fist0

What is the effect of calling the Sort() method on a List<string> in C#?

easy🧠 Conceptual Q2 of Q15
C Sharp (C#) - Collections
What is the effect of calling the Sort() method on a List<string> in C#?
AIt removes duplicate elements from the list.
BIt reverses the order of elements in the list.
CIt arranges the elements in ascending alphabetical order.
DIt converts all elements to uppercase.
Step-by-Step Solution
Solution:
  1. Step 1: Understand Sort()

    The Sort() method sorts the list elements in ascending order by default.
  2. Step 2: Apply to strings

    For strings, ascending order means alphabetical order (A to Z).
  3. Final Answer:

    It arranges the elements in ascending alphabetical order. -> Option C
  4. Quick Check:

    Sorting strings alphabetically [OK]
Quick Trick: Sort() arranges list elements in ascending order [OK]
Common Mistakes:
MISTAKES
  • Thinking Sort() reverses the list
  • Assuming Sort() removes duplicates
  • Believing Sort() changes element case

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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