- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
- Related Articles
- C# program to get the last element from an array
- C# Program to find the smallest element from an array
- C# Program to find the largest element from an array
- Program to get the last element from an array using C#
- Write a Java program to find the first array element whose value is repeated an integer array?
- PHP program to delete an element from the array using the unset function
- How to get the first element of an array in PHP?
- Finding the first redundant element in an array - JavaScript
- C# Program to find the smallest element from an array using Lambda Expressions
- C# Program to find the largest element from an array using Lambda Expressions
- Java Program to Get First and Last Elements from an Array List
- Golang Program To Get The First Item From The Array
- C++ Program to get the first item from the array
- Projection of arrays to get the first array element from MongoDB documents
- Golang Program to remove given element from the array

Advertisements