Filter Ranges of Elements with Take and Skip - CSharp LINQ

CSharp examples for LINQ:where

Description

Filter Ranges of Elements with Take and Skip

Demo Code


using System;/*from   w  ww . j a v  a  2  s .c  o m*/
using System.Collections.Generic;
using System.Linq;
using System.Text;

class MainClass
    {
        static void Main(string[] args)
        {
            string[] array = { "one", "two", "three", "four", "five" };

            IEnumerable<string> skipresult = from e in array.Skip<string>(2) select e;
            foreach (string str in skipresult)
            {
                Console.WriteLine("Result from skip filter: {0}", str);
            }

            IEnumerable<string> takeresult = from e in array.Take<string>(2) select e;
            foreach (string str in takeresult)
            {
                Console.WriteLine("Result from take filter: {0}", str);
            }

        }
    }

Result


Related Tutorials