MSDN gives this sample code in an article on the Func Generic Delegate :
Func<String, int, bool> predicate = ( str, index) => str.Length == index;
String[] words = { "orange", "apple", "Article", "elephant", "star", "and" };
IEnumerable<String> aWords = words.Where(predicate).Select(str => str);
foreach (String word in aWords)
Console.WriteLine(word);
I understand that all this does. What i don't understand is
Select(str => str)
Little. Is it really not necessary? If you leave it and just
IEnumerable<String> aWords = words.Where(predicate);
then you still get IEnumerable back that contains the same results, and the code prints the same.
Am I missing something, or is this a misleading example?
source
share