after finishing while loop,when it wants to quit the recursive( node curr) method,it comes back again to the recursive call(recursive (nod)) in the for loop and it traps in several loops till an exception occurs saying that "index was out of the rang of the array" .
can anyone help please...

public void recursive(Node curr)
{

while ( sour <= source.Length - 2)

{
for (int i = 0; i < curr.ChildNumber; i++)
{
nod = (Node)curr.nextNode[i];
while (source[sour] != nod.CurrentNodeName)
{
continue;

}
sour = sour + 1;
Console.WriteLine(nod.CurrentNodeName);
recursive((Node)nod);

}
sour = sour + 1;
}


}

You have all your logic in a big tangled mess.

I suggest you start by writing in pseudo code what you want to do and then code. You have while loops that do nothing, while loops inside for loops inside while loops and call the same method inside all those loops. A recipe for disaster.

You can simplify this greatly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.