Code: Throwing an Exception (Visual C#)

Code: Throwing an Exception (Visual C#)

Visual Studio .NET 2003

This example throws the exception System.ApplicationException.


throw new ApplicationException();

Compiling the Code

Copy the code and paste it into the Main method of a console application.

Robust Programming

Unhandled exceptions cause application execution to stop.

See Also

Code: Catching an Exception (Visual C#) | throw | try-catch | ApplicationException Class | Exception Class | General Language Example Topics

© 2016 Microsoft