Bird
Raised Fist0

What will be the output of this C# code?

medium📝 query result Q5 of Q15
C Sharp (C#) - Collections
What will be the output of this C# code?
var items = new List {"a", "b", "c"};
items.RemoveAt(1);
Console.WriteLine(items[1]);
Ac
Bb
Ca
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand RemoveAt effect

    RemoveAt(1) removes the element at index 1, which is "b".
  2. Step 2: Check new element at index 1

    After removal, "c" moves to index 1, so items[1] is "c".
  3. Final Answer:

    c -> Option A
  4. Quick Check:

    Index 1 after RemoveAt = "c" [OK]
Quick Trick: RemoveAt shifts elements left, changing indexes [OK]
Common Mistakes:
MISTAKES
  • Expecting removed element still at index
  • Confusing RemoveAt with Remove
  • Thinking index 1 is empty

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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