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
A Nathik
NA
1
1.9k
inner exception query
Nov 29 2014 8:44 PM
Hi,
I'm a newbie to C#. Trying to work on Inner exception but however the following code doesn't seem to work. Can you please help me out?
Thanks in advance!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ExceptionHandling
{
class Program
{
static void Main(string[] args)
{
try
{
try
{
Console.WriteLine("Enter your first number");
int FN = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter your Second number");
int SN = Convert.ToInt32(Console.ReadLine());
int Result = FN / SN;
Console.WriteLine("Result is {0}", FN/SN);
Console.ReadLine();
}
catch (Exception E)
{
string path = @"C:\Users\abdulhanannajjara\Desktop\Test.txt";
if(File.Exists(path))
{
StreamWriter SW = new StreamWriter(path);
SW.Write(E.Message);
//SW.Write();
SW.WriteLine(E.Message, E.Source);
SW.Close();
Console.WriteLine("There is a problem");
}
else
{
throw new FileNotFoundException("File not found" + path, E);
}
}
}
catch(Exception ex)
{
Console.WriteLine("Current Exception {0}", ex.GetType().Name);
Console.WriteLine("Inner Exception {1}", ex.InnerException.GetType().Name);
}
}
}
}
Reply
Answers (
2
)
Good Company for corporate training in noida
Microsoft Certification