I have the following code that compares the node.Texto each both given node sets and then return one if they are equal otherwise zero. But my problem is that it just compare the first children because of nodes2.Nodes[ii] hence I know that it will not go forward more.
As I know if it was TreeNodeCollection it was easy to do recursive for each node and sub-node using foreach loop.
But here how I could change the code to the recursive version? thanks in advance!
public int Compare_ChildNodes(TreeNode nodes1, TreeNode nodes2) { int length_children1 = nodes1.Nodes.Count; int length_children2 = nodes2.Nodes.Count; int result_int = 1; if (length_children1 != length_children2) { result_int = 0; } else { for (int ii = 0; ii < length_children1; ii++) { if (nodes1.Nodes[ii].Text.Equals(nodes2.Nodes[ii].Text)) { int ret = Compare_ChildNodes(nodes1.Nodes[ii], nodes2.Nodes[ii]); result_int = ret; } else { result_int = 0; } } } return result_int; }