为什么这个Func <>委托的MSDN示例有一个多余的Select()调用?

Tar*_*aal 5 c# msdn delegates

MSDN在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);
Run Code Online (Sandbox Code Playgroud)

我明白这一切是做什么的.我不明白的是

Select(str => str)
Run Code Online (Sandbox Code Playgroud)

位.当然不需要吗?如果你把它留下来就可以了

IEnumerable<String> aWords = words.Where(predicate);
Run Code Online (Sandbox Code Playgroud)

然后你仍然得到一个包含相同结果的IEnumerable,并且代码打印相同的东西.

我错过了什么,或者是误导性的例子?

Aar*_*ght 9

Select确实是多余的.

我怀疑这个例子可能是从查询理解语法中"翻译过来的",如:

IEnumerable<String> aWords = 
    from w in words
    where (...)
    select w;
Run Code Online (Sandbox Code Playgroud)

当使用这种语法,你必须select在最后,它的编译器是如何工作的.Where但是,在使用扩展方法时,除非您确实需要单独进行投影,否则完全没有必要.

或者,也许这只是一个错误.MSDN编写者并非万无一失!