Go to next instruction - C #

-2

I have if and need to be in case it is true it gives the message below and soon after it pauses the system or continues in another statement. I left the word BREAK to exemplify where I need this encoding (but BREAK does not work):

if (lanceSelecionado.ID_LANCE == null)
{
  await DisplayAlert("Comunicado", "Selecione um lance para exclusão!", "Ok");
  BREAK;
}
    
asked by anonymous 25.05.2018 / 22:17

2 answers

2

You can use return; if it is a void return function, for example:

public void NomeDaFuncao()
{
    if (lanceSelecionado.ID_LANCE == null)
    {
      await DisplayAlert("Comunicado", "Selecione um lance para exclusão!", "Ok");
      return;
    }
}

If it is a function with any type of return it is necessary to make return together with a default value, for example:

public int NomeDaFuncao()
{
    if (lanceSelecionado.ID_LANCE == null)
    {
      await DisplayAlert("Comunicado", "Selecione um lance para exclusão!", "Ok");
      return 0;
    }
}

The return function returns something and stops executing the function. It will only execute something else if it is inside a block try finally , in those cases what is inside finally will be executed.

    
25.05.2018 / 22:37
-1

Well your question is a bit vague. If you wanted to continue another statement, just call a method after the DisplayAlert. If you wanted to stop the application you can use System.Threading.Thread.Sleep(1000); or Console.ReadLine() (the application will return after pressing any key). Well you have N ways to implement what you want and if you specify better we can help you in the most appropriate way.

    
25.05.2018 / 22:24