Web
Analytics
LINQ Skip with example | Angular | ASP.NET Tutorials

For Consultation : +91 9887575540

Stay Connected :

The Skip query operator will ignore the specified number of input elements from the start of the input sequence and return the remainder.
The following code skips over the first three elements and returns the rest:

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LINQExample
{
    class Program
    {
        static void Main(string[] args)
        {
            Ingredient[] ingredients =
            { new Ingredient { Name = "Sugar", Calories = 500 }, 
                new Ingredient { Name = "Egg", Calories = 100 }, 
                new Ingredient { Name = "Milk", Calories = 150 }, 
                new Ingredient { Name = "Flour", Calories = 50 },
                new Ingredient { Name = "Butter", Calories = 200 } };
            IEnumerable<Ingredient> query = ingredients.Skip(3); 
            foreach (var ingredient in query)
            {
                Console.WriteLine(ingredient.Name); 
            }
            Console.ReadLine();
        }
    }
    public class Ingredient
    {
        public string Name;
        public int Calories;
    }


}

Output

LINQ_Skip_Method

Download Source Code