take and takewhile in c# code example
Example 1: takewhile c# example
IList<string> strList = new List<string>() {
"One",
"Two",
"Three",
"Four",
"Five",
"Six" };
var resultList = strList.TakeWhile((s, i) => s.Length > i);
foreach(string str in resultList)
Console.WriteLine(str);
Example 2: takewhile c# example
IList<string> strList = new List<string>() {
"Three",
"Four",
"Five",
"Hundred" };
var result = strList.TakeWhile(s => s.Length > 4);
foreach(string str in result)
Console.WriteLine(str);