Horje
C# walk down a tree and back Code Example
C# walk down a tree and back
public static IEnumerable<T> Traverse<T>(T item, Func<T, IEnumerable<T>> childSelector)
{
    var stack = new Stack<T>();
    stack.Push(item);
    while (stack.Any())
    {
        var next = stack.Pop();
        yield return next;
        foreach (var child in childSelector(next))
            stack.Push(child);
    }
}




Csharp

Related
.netstandard distinctby iqueryable Code Example .netstandard distinctby iqueryable Code Example
Winform on exit run method Code Example Winform on exit run method Code Example
c# directory entry invoke Code Example c# directory entry invoke Code Example
unity prefab button not working Code Example unity prefab button not working Code Example
c# guid from string Code Example c# guid from string Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8