IEnumerable<char> query = "Not what you might expect";
string vowels = "aeiou";
for (int i = 0; i < vowels.Length; i++)
query = query.Where (c => c != vowels[i]);
foreach (char c in query) Console.Write (c);
Exception occurs IndexOutOfRangeException. Why this exception occurs every thing looks fine.
Thanks in advance.
Solution
for (int i = 0; i < vowels.Length; i++)
{
char vowel = vowels[i];
query = query.Where (c => c != vowel);
}
This works fine, what is the difference between these codes. kindly, share the details.