
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
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