What should I do to stop running a method before it finishes, quits, and continues execution?
public void MEUMETODO()
{
...
PARA E SAIR AQUI();
...
}
What should I do to stop running a method before it finishes, quits, and continues execution?
public void MEUMETODO()
{
...
PARA E SAIR AQUI();
...
}
There are two ways to exit / terminate the function:
You can use return;
at any time to end the function:
public void MEUMETODO()
{
...
return;
...
}
Or use Throw
when an exception occurs:
public void MEUMETODO()
{
try
{
...
}
catch (Exception)
{
throw;
}
}