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# Program to display the first element from an array
The following is our array −
double[] myArr = {20.5, 35.6, 45.7, 55.6, 79.7};
To get the first element, use the First() method.
myArr.AsQueryable().First();
Let us see the complete code −
Example
using System;
using System.Linq;
using System.Collections.Generic;
class Demo {
static void Main() {
double[] myArr = {20.5, 35.6, 45.7, 55.6, 79.7};
double res = myArr.AsQueryable().First();
Console.WriteLine(res);
}
}
Output
20.5
Advertisements
