ElementAt() is a System.Linq method in C# that is used to get and display element at a particular index.
The following is our string array −
string[] arr = { "One", "Two", "Three", "Four", "Five" };Now to get an element at index 0, use the ElementAt() method −
arr.ElementAt(0);
The following is the complete code −
Example
using System.IO;
using System;
using System.Linq;
public class Demo {
public static void Main() {
string[] arr = { "One", "Two", "Three", "Four", "Five" };
// displaying element at index 0
string res = arr.ElementAt(0);
Console.WriteLine(res);
}
}Output
One