ExtCollection.cs 381 B

1234567891011121314151617
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace Island.StandardLib.Xinq
  6. {
  7. public static class ExtCollection
  8. {
  9. public static T WhereFirst<T>(this ICollection<T> ts, Func<T, bool> where)
  10. {
  11. foreach (T t in ts)
  12. if (where(t)) return t;
  13. return default;
  14. }
  15. }
  16. }