0
No, having just tried it, the code's not working and has a lot of problems.
I think you're trying to do too much with your exception classes, Shreya, which are really just providing information about some error that has occurred and rarely need to do any calculations.
As the question you've been given is vague, I'd just do something minimal like the following:
using System;
namespace ExceptionClasses
{
public class Excep : System.ApplicationException
{
public Excep(string message) : base(message)
{
}
}
public class ChildExcep1 : Excep
{
public ChildExcep1(string message) : base(message)
{
}
}
public class ChildExcep2 : Excep
{
public ChildExcep2(string message) : base(message)
{
}
}
class MainClass
{
public static void Main()
{
try
{
throw new ChildExcep1("Child1 exception thrown");
}
catch (Excep e) // catch with base exception clause
{
Console.WriteLine(e.Message);
}
try
{
throw new ChildExcep2("Child2 exception thrown");
}
catch (Excep e) // catch with base exception clause
{
Console.WriteLine(e.Message);
}
}
}
}
The output should be:
Child1 exception thrown
Child2 exception thrown

0
not sure what the question is , is this not working?