Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Recursive: See recursive
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01083365
Message ID:
01083589
Views:
12
Hi,

Glad it worked. Can you get rid of the CallRecursive() all together by simply passing the root node to RecursiveMethod()?

Best,
Viv

>Thank you. I meant to give you three stars but accedentaly hit the one star button , so here are the additional 2 stars: **.
>The final code looks something like this:
>
>
>private void CallRecursive(TreeView treeView)
>{
>   foreach (TreeNode n in treeView.Nodes)
>   {
>      if (RecursiveMethod(n))
>      {
>        break;
>      }
>   }
>}
>
>
>private bool RecursiveMethod(TreeNode treeNode)
>{
>   if (foo == bar)
>   {
>     MessageBox.Show(treeNode.Text); // I don't want to continue my recursive search!!
>      return true;
>   }
>
>   foreach (TreeNode tn in treeNode.Nodes)
>   {
>      if (RecursiveMethod(tn))
>      {
>        return true;
>      }
>   }
>   return false;
>}
>
>
>
>>Hi,
>>How about:
>>
>>private bool RecursiveMethod(TreeNode treeNode)
>>{
>>   if (foo == bar)
>>   {
>>     MessageBox.Show(treeNode.Text); // I don't want to continue my recursive search!!
>>      return true;
>>   }
>>
>>   foreach (TreeNode tn in treeNode.Nodes)
>>   {
>>      if (RecursiveMethod(tn)) return true;
>>   }
>>   return false;
>>}
>>( and update the calling method to match)
>>
>>HTH,
>>Viv
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform