A day with .Net

My day to day experince in .net

Partitioning Data skip,skip-while,take,take-while

Posted by vivekcek on October 8, 2012

 string[] test5 = new string[] { "an", "apple", "a", "day", "keeps", "the", "doctor", "away" };
            IEnumerable<string> take = test5.Take(3);
            IEnumerable<string> skip = test5.Skip(3);
            IEnumerable<string> skipWhile = test5.SkipWhile(x => x.Substring(0, 1) == "a");
            IEnumerable<string> takeWhile = test5.TakeWhile(x => x.Length <= 3);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s