第一次遇到,标记一下.

上段代码应该都明白了怎么用

public static IEnumerable<T> FindWhere<T>(IEnumerable<T> collection, Predicate<T> predicate)
{
    if (collection == null)
        throw new ArgumentNullException("collection");
    if (predicate == null)
        throw new ArgumentNullException("predicate");

    foreach (T item in collection) {
        if (predicate(item)) {
            yield return item;
        }
    }
}

 

貌似是用于返回对象是IEnumerable或IEnumerable<T>的

相关文章:

  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
  • 2021-06-21
  • 2021-11-20
  • 2021-07-01
猜你喜欢
  • 2021-09-08
  • 2021-06-19
  • 2021-10-21
相关资源
相似解决方案