SkipWhile Method in Linq

I have been playing around linq and I have found great method call SkipWhile method. SkipWhile methods skips particular element which matches condition in predicate this can be use full in condition where we need to skip elements on particular condition.

So let’s take some example. I have written following console application code.

using System;
using System.Collections.Generic;
using System.Linq;
namespace Linq
  class Program
      static void Main(string[] args)
          string[] names = { "Jalpesh", "Jayesh", "Tushar", "Tejas", "Sanjay", "Nijesh" };
          foreach(var name in names.SkipWhile(s=>s.ToLower().StartsWith("j")))

In the above code I have created a array of string called names and I want to skip names starts with letter “j” with help of ‘SkipWhile’. I am printing each item via for each loop. Following is the output as expected.


That’s it.Hope you liked it. Stay tuned for more..Till then happy programming.

Shout it

kick it on


  1. Sorry if I'm being dense; couldn't you also use a Where clause for this?

  2. blaster151 - There is major difference between skipwhile and where. Where filters the things. While skipwhile skip the elements until condition is true . I will post a blog on that


Post a Comment

Your feedback is very important to me. Please provide your feedback via putting comments.

Popular posts from this blog

Creating PDF with ASP.Net MVC and RazorPDF

Horizontal and vertical scrollbar in HTML5 and CSS3

How to create Rest API(Web API) with ASP.NET Core 1.0