In LINQ, ElementAt() operator is used to return element from list / collection based on specified index position.
Generally, the list index will start with zero, so we need to send zero (0) as the index position if we want to get the first element.
Following is the syntax of using the LINQ ElementAt() method to get elements at specified index positions in the list/collection.
If you observe the above syntax, we get elements at the second index position element from the collection.
Following is the example of using the LINQ EelementAt() method to get elements at a specified index position.
If you observe the above example, we are trying to get different elements in the collection based on different index positions.
Following is the result of the LINQ ElementAt() method example.
In case if we pass the index position that does not exist in the list/collection, it will throw an “ArgumentOutOfRangeException” error.
This is how we can use LINQ EelementAt() method to get the element at a specified index position in c#, vb.net.