The text of this article is not in this database — only its details are. The old site it was published on is gone, but the Internet Archive kept a copy: How to Use Take/TakeWhile and Skip/SkipWhile in LINQ
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

Sathishkumar SubramaniPosted Oct 27, 2014, 6:31 AM
The below Example are wrong. I think the result will be "one,two,three,four". Beacause the condition fails in the case of "five" whose length(4) is not greater than the index(4). Please verify it.Example III: String colection = { "one", "two", "three", "four", "five" }; var strings = collection.TakeWhile((s, index)=> s.Length > index ); In this example the TakeWhile will return the items starting from the beginning of the array until a string length is greater than it's position in the collection. So this example will return "one" and "two". Because the "three" has the length of 5 and its position [index] is 2. Since 2 is less than 5 the condition fails at "three"
Raj KumarPosted Jun 7, 2011, 3:30 AM
nice