Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of End (VB6/VBA) in order to end in C# for Windows applications?

Tags:

c#

vb6

What is the equivalent of End (VB6/VBA) in order to end an application using C#?

like image 379
odiseh Avatar asked Jan 09 '10 11:01

odiseh


People also ask

What is End C#?

In C#, EndsWith() is a string method. This method is used to check whether the ending of the current string instance matches with a specified string or not. If it matches, then it returns the string otherwise false. Using “foreach” loop, it is possible to check many strings.

How do you end a program in VB net?

Just Close() all active/existing forms and the application should exit.

Does C# have a with statement?

There's no with keyword in C#, like Visual Basic. So you end up writing code like this: this. StatusProgressBar.


2 Answers

The marked answer is not correct. Application.Exit() is a graceful shutdown, it can be blocked by a form's FormClosing event handler setting e.Cancel = true. The exact equivalent to the VB End statement is Environment.Exit(0);

like image 101
Hans Passant Avatar answered Nov 23 '22 16:11

Hans Passant


To terminate Windows Forms application use:

Application.Exit();

To terminate a console application you must return the main function.

like image 26
André Pena Avatar answered Nov 23 '22 16:11

André Pena