Category Archive for: Errors and Exceptions

User-Defined Exception Classes

You are now ready to look at a second example that illustrates exceptions. This example, called SolicitColdCall, contains two nested try blocks and also illustrates the practice of defining your own custom exception classes and throwing another exception from Inside a try block. This example assumes that a sales company wants to have additional customers on its…

Read More →

Catching Exceptions

Given that the .NET Framework includes a selection of predefined base class exception objects, how do you use them in your code to trap error conditions? To deal with possible error conditions in C# code, you will normally divide the relevant part of your program into blocks of three different types: try blocks encapsulate the code that…

Read More →

Exception Classes

In C#, an exception is an object created (or thrown) when a particular exceptional error condition occurs. This object contains information that should help track down the problem. Although you can create your own exception classes (and you will be doing so later), .NET provides you with many predefined exception classes. This section provides a quick survey of…

Read More →

Errors and Exceptions

Errors happen, and they are not always caused by the”person who coded the application. Sometimes your application will generate an error because of an action that was initiated by the end user of your application or it might be simply due to the environmental context in which your code is running. In any case, you should anticipate errors…

Read More →

Back to Top