Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2005

Tip: Looking for answers? Try searching our database.

Silly Try Catch question...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John - 11 Jul 2005 12:32 GMT
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
 

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.