Alessandro
8
Q:

exit a method c#

Application.Exit();
2
if (System.Windows.Forms.Application.MessageLoop) 
{
    // WinForms app
    System.Windows.Forms.Application.Exit();
}
else
{
    // Console app
    System.Environment.Exit(1);
}
1
System.Environment.Exit(1);
2
 Application.Exit();
1
// In a console application:
Environment.Exit(0);
// In a WPF application:
Close();
1
Use "break;"
  
for (int i = 1; i <= 100; i++)
{
	if (i == 5)
	{
		break;
	}
}
1
private void Test(int condition)
{
  if(condition)
    return; // Exit the methode

  // Here code if condition == false
}
1
System.Windows.Forms.Application.ExitThread( )
-1

New to Communities?

Join the community