Hello I know this is extremely basic, I just want to make sure I got it right.
is:
try{}
catch{}
the same as
try{}
catch(System.Exception e){}
I mean if I am not using the reference to the exception then I should simply
use
catch{} ? or is catch(System.Exception){} somehow more restricted on what
it catches than simply catch{}?
Thanks in advance
JT.
Peter van der Goes - 11 Jul 2005 14:10 GMT
> Hello I know this is extremely basic, I just want to make sure I got it
> right.
[quoted text clipped - 18 lines]
>
> JT.
System.Exception is the base class for all exception types, therefore not
restrictive. To find out why your try catch blocks should always use a
parameter of type Exception (or subclass thereof), I suggest you look into
the important properties shared by these classes, such as Message (a string
containing a readable description of the raised exception).

Signature
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Jay B. Harlow [MVP - Outlook] - 11 Jul 2005 14:28 GMT
John,
In addition to the other comments.
For C# & VB.NET code both are the same, as both languages only support
throwing exceptions that inherit from System.Exception.
However! If you call another language that allows you to throw exceptions
that do not derive from System.Exception will cause the two statements to be
semantically different.
For details see:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vcl
rfcsharpspec_8_10.asp
Hope this helps
Jay
| Hello I know this is extremely basic, I just want to make sure I got it right.
|
[quoted text clipped - 16 lines]
|
| JT.
John - 11 Jul 2005 14:57 GMT
Thanks!
Very helpful
JT.
> John,
> In addition to the other comments.
[quoted text clipped - 35 lines]
> |
> | JT.
John - 11 Jul 2005 15:05 GMT
Actually I am glad I posted this on
"microsoft.public.dotnet.academic" and on:
"microsoft.public.dotnet.general"
as I now discovered I got the wrong answer on
"microsoft.public.dotnet.general"
check it out:
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.dotnet.gen
eral&tid=d2af9c58-e39d-4b8d-811b-8e7c31eabb89&cat=en-us-msdn&lang=en&cr=US&sloc=
en-us&m=1&p=1
Alvin Bruney [MVP - ASP.NET] - 13 Jul 2005 18:51 GMT
no, the reply to your thread is entirely correct in .net.general. if you
need more detailed information, have a read of jeffrey richters book -
applied framework programming

Signature
Regards,
Alvin Bruney - ASP.NET MVP
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
> Actually I am glad I posted this on
>
[quoted text clipped - 7 lines]
>
> http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.dotnet.gen
eral&tid=d2af9c58-e39d-4b8d-811b-8e7c31eabb89&cat=en-us-msdn&lang=en&cr=US&sloc=
en-us&m=1&p=1