Start learning free

LESSON 105 OF 674 · ARRAYS I

Arrays in C#

Lesson

The entries of a List<T> are mutable and can be changed freely, by assigning to an index with square brackets:

Writing list[index] = value changes the element placed at that index to the new value:

List<int> numbers = new List<int>(new[] {50, 40, 30});

numbers[0] = 15;
numbers[2] = -1;

// numbers is now [15, 40, -1]

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