We can access the data inside a List using indexes and the [] operator, just like with arrays.
Lists also use zero-based indexing, so the first element in a List has an index of 0.
List<int> numbers = new List<int> {50, 60, 70};
Console.WriteLine(numbers[0]); // Output: 50
int data = numbers[1];
Console.WriteLine(data); // Output: 60
Assignment
Follow the Coding Tutorial and let's play with some lists.
Hint
Look at the examples above if you get stuck.
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
