Tag Archives: try catch

A quick note on error messages

I went to a local museum the other day and when the attendant scanned by membership card his computer said: Object not set to a reference of an object. Because we’re programmers, you and I know what that means (more … Continue reading

Posted in MessageBox, miscellany, user interface | Tagged , , , , , , , , , , , , , | 1 Comment

Define custom exception classes in C#

The example Throw a standard exception in C# explains how to throw exceptions to tell the program about unexpected errors. The example See a hierarchy of exception classes for use in C# lists some useful exception classes. But what if … Continue reading

Posted in coding | Tagged , , , , , , , , , , , , , | Leave a comment

See a hierarchy of exception classes for use in C#

The example Throw a standard exception in C# explains how to throw exceptions to indicate a problem in a program. Throwing an exception is easiest if you can find an existing exception class that correctly represents your situation. The following … Continue reading

Posted in coding | Tagged , , , , , , , , , , , | 2 Comments

Throw standard exceptions in C#

The example Use try catch blocks to protect against unexpected errors in C# explains how to catch an exception and briefly mentions that you can use the throw statement to throw your own exception. This example shows how to throw … Continue reading

Posted in coding | Tagged , , , , , , , , , , , | 2 Comments

Understand when a finally block is executed in C#

Many programmers don’t understand (and many have forgotten) how the try catch finally block works. The basic syntax is: try { // Statements that could cause an error… } catch (Exception ex) { // Statements to execute if there is … Continue reading

Posted in syntax | Tagged , , , , , , , , , , , , | Leave a comment

Use try catch blocks to protect against unexpected errors in C#

Most programs cannot anticipate every possible error. You can watch for things like missing files, but it’s hard to stop a determined user from entering “ten” in a TextBox that should contain a number. (Actually you can prevent that by … Continue reading

Posted in debugging, syntax | Tagged , , , , , , , , , , , , , , | 1 Comment