Many software development communities have a very large thread in the forum about coding styles horror. Most of the posted code snippets are about exception handling, which shows how difficult this topic is. Therefore, we must talk about exception handling first, along with what to do and what not to do.
This part gives you an initial introduction to exception handling in Silverlight and a warm up for all developers who are familiar with this topic.
Let's have a look at the syntax of the easiest expression in exception handling:
try { // Statement } catch (FileNotFoundException e) { // Statement } catch (IOException) { // Statement } catch { // Statement }
The try
block contains the statements that might throw an exception. If no runtime exception occurs, all statements in the try
block will be executed; otherwise the flow of control immediately jumps to an associated exception handler, if one is present.
You can specify any type that derives...