Skip to content

Instantly share code, notes, and snippets.

Created December 27, 2012 16:10
Show Gist options
  • Save anonymous/4389415 to your computer and use it in GitHub Desktop.
Save anonymous/4389415 to your computer and use it in GitHub Desktop.
public static IEnumerable<T> Descendants<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> DescendBy) {
foreach (T value in source) {
yield return value;
foreach (T child in DescendBy(value).Descendants<T>(DescendBy)) {
yield return child;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment