This is a discussion on Generic Exception Handling within the C Sharp forums, part of the Programming Talk category; I have written an exception in my C# code as below: catch(FileNotFoundException example) { Console.WriteLine(example.ToString()); } But the ...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have written an exception in my C# code as below:
catch(FileNotFoundException example) { Console.WriteLine(example.ToString()); } But the above would only catch exceptions when FileNotFoundException exception is thrown. I want to handle and catch other generic Exceptions also. How can I write exception for these? |
|
|||
|
The following would handle and catch other generic Exceptions
catch (Exception e1) { ................. ................... } In the catch block you can write code that does general error handling. finally { ................. ................... } In the above finally clock you can write code so that the whatever written in finally block of code gets executed irrespective of before events. |
|
|||
|
Exception handling
hi,
try { ... } catch(FileNotFoundException example) { Console.WriteLine(example.ToString()); } catch(Exception e) { Console.WriteLine(example.ToString()); } while doing this, if u got FileNotFoundException, the first catch block will execute, for any other exceptions, the generic exception catch block will execute... |
![]() |
| Thread Tools | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VB exception handling problems | dababy | Visual Basic Tutorials | 1 | 11-30-2006 06:48 PM |
| Visual Basic : Make the Transition from Traditional Visual Basic Error Handling to the Object-Oriented Model in .NET | techguru | Visual Basic Tutorials | 0 | 08-29-2005 07:27 AM |
| Visual Basic : .NET Remoting and Event Handling in VB .NET, Part 2 | techguru | Visual Basic Tutorials | 0 | 08-28-2005 07:27 PM |
| Visual Basic : .NET Remoting and Event Handling in VB .NET, Part 3 | techguru | Visual Basic Tutorials | 0 | 08-28-2005 03:26 PM |
| comp.lang.c Answers to Frequently Asked Questions (FAQ List) | Steve Summit | Tech FAQ | 0 | 06-01-2004 07:00 AM |