Different kind of Jump Statements in Csharp

Jump Statements : It is statement which transfer the execution from one line to another. C# has number of statements that allows us to jump to another line in a program.

  1. goto
  2. break
  3. continue
  4. return
1) goto : It allows us to jump directly to another specified line in the program, indicated by a lable                    which is an identifier followed by colon.
              



Output : - 


2) break : It is used to exit from a case in a  switch statement and also used to exit from any      conditional loop statement which will switch control to the statement immediately end of the loop.




3) continue : This can be used only in a loop. Which will jump the control to iteration part of the loop without executing any other statements present next to it.

4) return :  It is use to jump out of a function or a method under execution and while jumping out of it is capable of carrying a value out of that function or method in execution which is optional.


No comments:

Post a Comment