R
Raj
To create custom exception whether to inherit ApplicationException or
Exception?
The Message property returns different values if I use ApplicationException
and Exception. What is the difference between using these two??
namespace ConsoleApplication1
{
using System;
class MyException : Exception
{
public MyException(string str)
{
Console.WriteLine("User defined exception");
}
public override string ToString()
{
return Message;
}
}
class MyClient
{
public static void Main()
{
try
{
throw new MyException("Error Encountered");
}
catch (Exception e)
{
Console.WriteLine("Exception caught here" + e.ToString());
}
Console.WriteLine("LAST STATEMENT");
Console.Read();
}
}
}
Thank you
Regards
Raj
Exception?
The Message property returns different values if I use ApplicationException
and Exception. What is the difference between using these two??
namespace ConsoleApplication1
{
using System;
class MyException : Exception
{
public MyException(string str)
{
Console.WriteLine("User defined exception");
}
public override string ToString()
{
return Message;
}
}
class MyClient
{
public static void Main()
{
try
{
throw new MyException("Error Encountered");
}
catch (Exception e)
{
Console.WriteLine("Exception caught here" + e.ToString());
}
Console.WriteLine("LAST STATEMENT");
Console.Read();
}
}
}
Thank you
Regards
Raj