Start learning free

LESSON 111 OF 674 · ARRAYS I

Remove Items From List in C#

Lesson

Another way to change the data in an List is with the .RemoveAt() method.

.RemoveAt() takes one parameter which represents an index and removes the element placed at that index:

List<int> threeArr = new List<int>(new[] {1, 4, 6});

// Remove second element:
threeArr.RemoveAt(1);

// threeArr is now [1, 6]

// Remove first element:
threeArr.RemoveAt(0);

// threeArr is now [6]

Assignment
Follow the Coding Tutorial and let's play with some arrays.


Hint
Look at the examples above if you get stuck.


STEP 1 OF 2
    Ctrl + Enter to check