TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maha
NA
0
328.4k
Exception handling
Sep 18 2013 9:50 AM
http://www.dotnetperls.com/exception
Following program is given in the above website (3rd program). Without try and catch it is giving the same output. So what is the purpose of using try and catch.
using System;
using System.Collections;
class Program
{
static void Main()
{
//try
//{
// Create new exception.
var ex = new DivideByZeroException("Message");
// Set the data dictionary.
ex.Data["Time"] = DateTime.Now;
ex.Data["Flag"] = true;
// Throw it!
//throw ex;
//}
//catch (Exception ex)
//{
// Display the exception's data dictionary.
foreach (DictionaryEntry pair in ex.Data)
{
Console.WriteLine("{0} = {1}", pair.Key, pair.Value);
}
//}
Console.ReadKey();
}
}
/*
Time = 18/09/2013 9:34:38 AM
Flag = True
*/
Reply
Answers (
5
)
Size of an empty class in C#
not getting full value