The element operators extract one element from the input sequence : ElementAt : LINQ C# Source Code


Custom Search

C# Source Code » LINQ » ElementAt »

 

The element operators extract one element from the input sequence








    
 
//First, Last, Single, and ElementAt

using System;
using System.Collections.Generic;
using System.Linq;
public class MainClass {
    public static void Main() {

        int[] numbers = { 10, 9, 8, 7, 6 };
        int firstNumber = numbers.First();    
        int lastNumber = numbers.Last();      
        int secondNumber = numbers.ElementAt(1);
        int lowestNumber = numbers.OrderBy(n => n).First();
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo LINQ
» ElementAt