[Mono-dev] Action<T> used
p.zurek at gmail.com
Mon Jul 10 23:06:18 EDT 2006
I have created a simple tree structure using List<T>.
Below is the metod that I use to count all the nodes in that structure.
public void CountDescendants()
_totalcount = 0;
Queue<Node> todo = new Queue<Node>();
while (todo.Count > 0)
Node node = todo.Dequeue();
foreach (Node child in Node.Subnodes) todo.Enqueue(child);
I have been podering on how to create a simple ForEach method for my
Node class that would allow me executing different commands on all
elements of the tree.
Probably the Action<T> delegate is the way to go here but I ain't got
a clue how to use it. Any ideas?
More information about the Mono-devel-list