HOW TO INTERRUPT A SUBRUTINE?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Happy Holidays!

To exit a subrutine I use Exit Sub in VB. Is there something similar in C#?

Thanks!!!

Raul
 
Raul M. Colon said:
Happy Holidays!

To exit a subrutine I use Exit Sub in VB. Is there something similar in
C#?

yes, 'return'.
 
Im not sure of other possible commands, but "Return" will probably work

Subroutine? Whats that?

If youre in a function thats declared as a void return, when it exits it
probably returns with zero then ignores the zero;
But you simply finish your subroutine with the last line of code and Exit
Sub is assumed? (Im assuming?)

Otherwise if you want to break out, it seems to me a "Return" should do it
 
If it doesn't return any values (i.e. it is a void method) then you can
simply use "return" to exit the method. If it does return a value though
then you'll have to specify something after the return keyword. In most
cases there is a default value that you can return - for example if it's a
boolean method you might want to return false by default. It really depends
on what the subroutine does.
~amit
 
Thanks for your help... 'return' did it.
I'm new in C#, trying to switch from VB.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top