I'm inside a for loop. How do I exit the for loop? And the sub?
Printable View
I'm inside a for loop. How do I exit the for loop? And the sub?
Inside a loop, you use the break; statement. To exit a method, use return;
C# = C++ when it comes to exiting.Quote:
Originally Posted by mendhak
Code:
for(int i = 0; i<10; i++)
{
if (!(i%2))
//divisible by 2
break; //break outter for
....
}
return; //get out of routine...although you should return some sort of status
I see, thanks a break!;