Mid Collections

What does Insert() do in a List<T> and how is it different from Add()?

  • Insert(index, item) adds an item at a specific index.
  • Add(item) adds to the end of the list.

Example:

list.Insert(0, 99); // Add at beginning

list.Add(100); // Add at end

More from C# Programming Tutorial

All questions for this course