ElementAt
If you have ever had to deal with arrays, to access a particular index in an array, you can simply use the square bracket notation like so: array[1]
. This will return the the item of the array at position 1. Well, how do you access a particular index in a list? You can use .ElementAt
.
Live example: https://dotnetfiddle.net/9zB000
var numbers = new[] { 2, 4, 6, 8, 10 };
int number = numbers.ElementAt(3);
//output: 8