Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

I am Jalpesh Vadgama a Microsoft MVP for Visual C# and BrainBench Certified ASP.NET Developer having more then 6 years of experience in .NET Technology.
Browse by Tags · View All
#ASP.NET 88
#DOTNET 87
BRH 79
ASP.NET 72
#.NET 52
C#.NET 48
DOTNET 44
ASP.NET 4.0 31
ASP.NET MVC 29
VisualStudio 27

Archive · View All
December 2010 16
July 2011 13
April 2011 13
April 2012 12
January 2011 12
June 2011 11
May 2011 11
May 2012 8
February 2013 7
January 2013 7

Difference between SkipWhile and Where in linq

Apr 17 2012 3:49AM by Jalpesh   

Before some time I have written a blog post about the SkipWhile operator and a reader of my blog asked me that we can do the same thing with Where also but there is a difference between this two. So In this post I am going to explain you difference between those two.

Where operator filters a list of collection based on condition. It will filter whole collection while SkipWhile will only skip those elements in list until condition is true and after that it will stop filtering of skipping. Now let’s take an example where we can see the difference between Where and SkipWhile. Following is a code for that.

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","Jemit","Jay" };

            Console.WriteLine("Skipwhile Operator");
            foreach (var name in names.SkipWhile(s => s.ToLower().StartsWith("j")))
            {
                Console.WriteLine(name);
            }
            Console.WriteLine("-----------------------------------");
            Console.WriteLine("Where Operator");
            foreach (var name in names.Where(s => !s.ToLower().StartsWith("j")))
            {
                Console.WriteLine(name);
            }
        }
    }
}

As you can see that in the above code I have a string array called names where I have people’s name as string. Here you can see there are multiple names start with letter “J” in array. Now once we use SkipWhile operator it will skip the elements untill condition is false for first time So it will skip the elements until condition satisfied for the first once you have different condition it will not going skip element even if they are satisfying the condition. While in where it will filter whole collection and print output.

Let’s run above example. Following is a output as expected.

image

That’s it. Hope you like it. Stay tuned for more. Till than happy programming.

Shout it

Tags: C#.NET, #LINQ, LINQ,


Jalpesh
15 · 11% · 3478
3
 
0
Lifesaver
 
0
Refreshed
 
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"Difference between SkipWhile and Where in linq" rated 5 out of 5 by 3 readers
Difference between SkipWhile and Where in linq , 5.0 out of 5 based on 3 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]