C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Exceptions in C#


Posted Date: 05 Nov 2007    Resource Type: Code Snippets    Category: Exceptions

Posted By: Ravi Kumar       Member Level: Silver
Rating:     Points: 5



This code is an eye opener to the way exceptions are handled in C#. At the face of it, it seems that the code will throw a runtime exception. But, thats were you are deceived! Since the division operation is hard-coded ( i.e. 15/0 ), the compiler throws a compiler error.This gives NO CHANCE for the catch block to be executed! However, if this condition was generated during runtime, it would be handled by the catch block. Eureka!!!



class ExceptionClass
{
static void Main()
{
try
{
Console.WriteLine(15/0);
}
catch(DivideByZeroException e)
{
Console.WriteLine("Exception throws:"+e);
}
}
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
How Exceptions are Handled  .  Exception Handling in C#  .  Exception Handling in .NET  .  Exception Handling  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Multiple Exception Analysis in C#
Previous Resource: How to save application errors(Exceptions occurs) in SQL Server Database
Return to Discussion Resource Index
Post New Resource
Category: Exceptions


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

accuconference

Contact Us    Privacy Policy    Terms Of Use