ElementAt() C# में एक System.Linq विधि है जिसका उपयोग किसी विशेष अनुक्रमणिका पर तत्व प्राप्त करने और प्रदर्शित करने के लिए किया जाता है।
हमारा स्ट्रिंग ऐरे निम्नलिखित है -
string[] arr = { "One", "Two", "Three", "Four", "Five" }; अब इंडेक्स 0 पर एक तत्व प्राप्त करने के लिए, ElementAt() विधि का उपयोग करें -
arr.ElementAt(0);
निम्नलिखित पूरा कोड है -
उदाहरण
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);
}
} आउटपुट
One