Try - Catch - Finally Statement

C# Error Handling

As a programmer, no matter how much precautions we take against errors that may occur on our web pages, there will always be errors caused by visitors or other reasons. For example, if the visitor should enter information in a text box, leaving it blank or entering different types of or incorrect information may cause an error.

In such errors, we do not want our pages to stop working and the visitor to be faced with an Asp.Net error page. As a precaution, the Try - Catch - Finally structure is very useful.

Structure and Usage of Try Catch Finally

try
{
Here we write the codes that we want to be done and that are likely to cause an error.
}
catch
{ If
an error occurs while performing the operations written in the try block, the operations here are performed. If there is no error, this block is skipped.
}
finally
{
If there is an error or not, we write the actions that we want to be done here. The finally block is optional, if not needed, it can be omitted.
}

using Try Catch Finally, try catch tutorials, how to use try catch, c# error handling

EXERCISES

There are no examples related to this subject.



COMMENTS




Read 555 times.

Online Users: 773



using-try-catch-finally