Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
C# Linq First() Method
Use the First() method to get the first element from an array.
Firstly, set an array.
int[] arr = {20, 40, 60, 80 , 100};
Now, use the Queryable First() method to return the first element.
arr.AsQueryable().First();
The following is the entire example.
Example
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main() {
int[] arr = {20, 40, 60, 80 , 100};
// getting the first element
int res = arr.AsQueryable().First();
Console.WriteLine(res);
}
}
Output
20
Advertisements
