4
What should I do to stop the execution of a method before it ends, get out and continue the execution?
public void MEUMETODO()
{
...
PARA E SAIR AQUI();
...
}
4
What should I do to stop the execution of a method before it ends, get out and continue the execution?
public void MEUMETODO()
{
...
PARA E SAIR AQUI();
...
}
8
There are two ways to quit/finish the function:
You can use a return;
at any time to end the function:
public void MEUMETODO()
{
...
return;
...
}
Or use the Throw
when an exception occurs:
public void MEUMETODO()
{
try
{
...
}
catch (Exception)
{
throw;
}
}
Browser other questions tagged c#
You are not signed in. Login or sign up in order to post.
If the method returned something as it would?
– ramaral
It seems to me a valid question, if basic. Why vote against?
– OnoSendai
@Onosendai I’m not sure, but perhaps it’s "This question shows no research effort". A negative vote is not always meaning the question is useless (which in this case is not) or is not explicit.
– CesarMiguel
@Precisely with the arming
– dcastro