Please look at following code in Linqpad and tell me why it returns 0 items instead of 1 items.
void Main()
{
string[] strArray = {"apple", "banana", "cherry", "e"};
List<string> lst = strArray.ToList();
//count all occurences of variable alphabet "e" in LINQ
//tip is to get the occurences of letter "e" in each word
// and then total them together
var lst2 = lst.TakeWhile(c=>c.Equals("banana")).Select(c=>c);
Console.WriteLine(lst2);
}
The above code does not return 1 item in linqpad as I would expect. Instead it returns 0 items. The list with 1 item "banana" should return. Why does it not?
Whereinstead of takewhilelst.TakeWhile(c=>c!="banana")