
- Forum
- Programming Talk
- C Sharp
- Generic Exception Handling
Generic Exception Handling
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 above would ...
-
Generic Exception Handling
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.
-
10-10-2007, 09:01 AM #3
- Join Date
- Oct 2007
- Answers
- 1
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...
-
Sponsored Ads

Reply With Quote





