What does goto and break mean in c#?

Showing Answers 1 - 0 of 0 Answers

george

  • Aug 11th, 2011
 

break means end up the loop while in the intermediate or end stage etc... when the program hit the break it will come out from the loop(for, while do-while etc) ..

goto is used to redirect the code to some other point by using label...

ex...
for(int i = 0; i < 10; i++)
{
if(i == 4)
{
break;
}
}
this will exit the loop when reaches the 4 and will not iterate further in this loop...

point: //label

for(int i = 0; i < 10; i++)
{
if(i == 4)
{
goto point; //re-direct to the label..
}
}

this is never end loop because whenever the point reaches in 4 it will go to the beginning point..

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions