Showing posts with label last in LINQ. Show all posts
Showing posts with label last in LINQ. Show all posts

Sunday, 18 August 2013

First and Last Method in LINQ

Written By:-Isha Malhotra 
Our Website:-www.techaltum.com    

First and Last in LINQ

Use of First in LINQ

First method in LINQ just select the top 1 value from the data source.

For Example:-

First with array

int[] marks = new int[] { 23, 45, 78, 45, 56, 89, 56, 32 };

       int first = marks.First();

       Response.Write("First Element " + first);
Ouput



We can also pass condition while calling first method