如何将 Linq 查询扩展方法与其在文档中的签名相关联?

How do I correlate a Linq query extension method to its signature in the documentation?

MSDN 中获取此代码:

The following code example demonstrates how to use Where(IEnumerable, Func) to filter a sequence.

List<string> fruits =
    new List<string> { "apple", "passionfruit", "banana", "mango", 
                    "orange", "blueberry", "grape", "strawberry" };

IEnumerable<string> query = fruits.Where(fruit => fruit.Length < 6);

foreach (string fruit in query)
{
    Console.WriteLine(fruit);
}
/*
 This code produces the following output:

 apple
 mango
 grape
*/

当我看签名的时候,

Where<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>)

(fruit => fruit.length < 6) 的哪一部分是 IEnumerable<TSource>Func<TSource, Boolean> 是包含整个 lambda 还是只包含 => 之后的内容?我猜想在幕后,Where's <TSource> 被编译器替换为通用的正确类型,但我不知道如何阅读其余部分。

编辑:如果这是一个委托而不是 lambda 是否更容易理解,就查看文档中指向的内容而言?

如果您查看方法签名,您会发现它定义为

public static Enumerable
{
    public static IEnumerable<TSource> Where<TSource>(
        this IEnumerable<TSource> source,
        Func<TSource, bool> predicate
    )
}

this 使它成为一种扩展方法。这样做

fruits.Where(fruit => fruit.Length < 6);

完全一样
Enumerable.Where(fruits, fruit => fruit.Length < 6);

所以要回答你的问题,IEnumerable<T>.

的左边