I'm reading the book "LINQ Pocket Reference" and there is a particular example (slightly modified below) that I'm having difficulty getting my head around... The explanation in the book is a bit brief, so I was wondering if someone could break it down step-by-step for me so that it makes sense...
IEnumerable<char> query2 = "Not what you might expect";
foreach (char vowel in "aeiou")
{
var t = vowel;
query2 = query2.Where(c => c != t);
// iterate through query and output (snipped for brevity)
}
Outputs this:
Not wht you might expect Not wht you might xpct Not wht you mght xpct Nt wht yu mght xpct Nt wht y mght xpct
Which makes perfect sense to me... However, this does not.
IEnumerable<char> query2 = "Not what you might expect";
foreach (char vowel in "aeiou")
{
query2 = query2.Where(c => c != vowel);
// iterate through query and output (snipped for brevity)
}
Not wht you might expect Not what you might xpct Not what you mght expect Nt what yu might expect Not what yo might expect
which doesn't...
Can someone give me a better explanation of exactly what is going on here?