Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. public static T Find<T>(
  2. this IEnumerable<T> source,
  3. Func<T, IEnumerable<T>> childrenSelector,
  4. Predicate<T> condition)
  5. {
  6. T t = default(T);
  7. foreach (T item in source)
  8. {
  9. if (condition(item))
  10. {
  11. return item;
  12. }
  13.  
  14. t = childrenSelector(item).Find<T>(childrenSelector, condition);
  15.  
  16. if (!Equals(t, default(T)))
  17. {
  18. return t;
  19. }
  20. }
  21. return t;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement