Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
ElementAt() method in C#
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
Advertisements