Get the 5th element : ElementAt « LINQ « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

public class MainClass{

   public static void Main(string[] args){   

         String[] TestData = {"Zero", "One", "Two", "Three",
                              "Four", "Five", "Six", "Seven", 
                              "Eight", "Nine", "Ten"};

         var ThisQuery = TestData.ElementAt(5);

         Console.WriteLine("Fifth Element: " + ThisQuery);
   }
}








22.32.ElementAt
22.32.1.Using ElementAt
22.32.2.The element operators extract one element from the input sequence
22.32.3.Calling the ElementAt Operator
22.32.4.Use ElementAt to print the fourth number less that 5 in an integer array
22.32.5.Get the 5th element