954,136 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

recusive method problem

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...

publicvoid 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;
}


}
paeez
Newbie Poster
11 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

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.

f1 fan
Posting Whiz in Training
279 posts since Jan 2006
Reputation Points: 26
Solved Threads: 11
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You