943,864 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1426
  • C# RSS
Jul 8th, 2007
0

recusive method problem

Expand Post »
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;
}


}
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
paeez is offline Offline
11 posts
since Feb 2007
Jul 10th, 2007
0

Re: recusive method problem

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.
Reputation Points: 26
Solved Threads: 11
Posting Whiz in Training
f1 fan is offline Offline
275 posts
since Jan 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: workink with list box in GUI
Next Thread in C# Forum Timeline: Help Needed in C# (picture viewer)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC