Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static T Find<T>(
- this IEnumerable<T> source,
- Func<T, IEnumerable<T>> childrenSelector,
- Predicate<T> condition)
- {
- T t = default(T);
- foreach (T item in source)
- {
- if (condition(item))
- {
- return item;
- }
- t = childrenSelector(item).Find<T>(childrenSelector, condition);
- if (!Equals(t, default(T)))
- {
- return t;
- }
- }
- return t;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement