Subscribe to Subscribers
Talk to Webmaster Tony John

Online Members

Pawan Awasthi
More...


Forums » .NET » General »

break


Posted Date: 01 May 2008      Posted By:: akku     Member Level: Silver    Member Rank: 2716     Points: 1   Responses: 4



ihave more than two loops in one function.. I have to exit from entire loop if one condition satisfies in the inner most loop.. Whats the Way
???????




Responses

#223530    Author: The Deep Blue Seas      Member Level: Silver      Member Rank: 0     Date: 01/May/2008   Rating: 2 out of 52 out of 5     Points: 2

Declare a boolean variable in the beginning and set its value to false as you move into the loops, when condition is true set bool to true.This will help you skip the rest of the loops and finally exit out of the function by calling break.

So typically your logic will be
if (!isExit)
{
for (...)
{
//set isExist to true or false here
}
}



 
#223580    Author: Shivshanker Cheral      Member Level: Gold      Member Rank: 26     Date: 02/May/2008   Rating: 2 out of 52 out of 5     Points: 2

So typically your logic will be
if (!isExit)
{
for (...)
{
if (some condition)
{
//set isExist to true or false here
isExist = true;
break; // exit from inner loop
}
if (isExist)
{
break; // exit from outer loop
}
}
}

Thanks
Shivshanker Cheral
"If you share your assets (money etc..) it will decrease, But if you share your knowledge it will increase!!! ".



 
#223667    Author: ChandraShekar Thota      Member Level: Gold      Member Rank: 35     Date: 02/May/2008   Rating: 2 out of 52 out of 5     Points: 2

Tell me in vb or c# so that i can give you code

Free Online,Offline Sessions
www.hyderabadtechies.info

chandrashekarthota@gmail.com /92 93 95 95 39
FREE SESSIONS ON .NET AND VISUALSTUDIO






 
#224327    Author: kunal badgujar      Member Level: Gold      Member Rank: 0     Date: 02/May/2008   Rating: 2 out of 52 out of 5     Points: 2

hi..

if (!isexit)
{
for ()
{
if (Isexit==true)
{
break;
}
}
}



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Failures
Previous : is it articles are removed.
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2012 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.