Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Understanding exception handler example in SDK

Reply
Thread Tools

Understanding exception handler example in SDK

 
 
Guest
Posts: n/a
 
      12-12-2004

I would appreciate some help in understanding the simple C# example relating
to handling exceptions. This one relates to catching an error thrown by
dividing number by zero.

There are a few things I don't understand which I hope you can help me with:




'using System;

class ExceptionTestClass
{
public static void Main()
{
int x = 0;
try
{
int y = 100/x;
}
catch (ArithmeticException e)
{
Console.WriteLine("ArithmeticException Handler: {0}",
e.ToString());
}
catch (Exception e)
{
Console.WriteLine("Generic Exception Handler: {0}",
e.ToString());
}
}
}

1. Is this class 'ExceptionTestClass a 'test' class for demonstration
purposes...why is there is not a general Exception class one could call
rather than the author's test?

2. The variable 'ArithmeticException' and 'e' ...are these standard incoming
variables from the excpection class or the author's exception class?

3. Why does he have two 'catch' classes....does the second one check the
first one to see if there was an error....

4. What is the difference between the 'ArithmeticException Handler and the
'Generic Exception Handler'.


I realise these are proabably naive questions but I am just starting out.

Thanks
Jason


 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      12-12-2004
Sorry wrong group!~!!


<> wrote in message
news:...
>
> I would appreciate some help in understanding the simple C# example

relating
> to handling exceptions. This one relates to catching an error thrown by
> dividing number by zero.
>
> There are a few things I don't understand which I hope you can help me

with:
>
>
>
>
> 'using System;
>
> class ExceptionTestClass
> {
> public static void Main()
> {
> int x = 0;
> try
> {
> int y = 100/x;
> }
> catch (ArithmeticException e)
> {
> Console.WriteLine("ArithmeticException Handler: {0}",
> e.ToString());
> }
> catch (Exception e)
> {
> Console.WriteLine("Generic Exception Handler: {0}",
> e.ToString());
> }
> }
> }
>
> 1. Is this class 'ExceptionTestClass a 'test' class for demonstration
> purposes...why is there is not a general Exception class one could call
> rather than the author's test?
>
> 2. The variable 'ArithmeticException' and 'e' ...are these standard

incoming
> variables from the excpection class or the author's exception class?
>
> 3. Why does he have two 'catch' classes....does the second one check the
> first one to see if there was an error....
>
> 4. What is the difference between the 'ArithmeticException Handler and the
> 'Generic Exception Handler'.
>
>
> I realise these are proabably naive questions but I am just starting out.
>
> Thanks
> Jason
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception of type 'System.Web.HttpUnhandledException' wasthrown.Exception has been thrown by the target of an invocation.System.WebSystem.Exception jobs ASP .Net 1 11-16-2007 05:57 PM
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
Event Handler that creates adds another event handler kaczmar2@gmail.com ASP .Net 1 02-22-2007 07:37 AM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
Exception handler for STATUS_GUARD_PAGE exception. Todd A. Anderson C++ 1 11-03-2004 05:08 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57