I tried to implement that code:
try
{
CheckDivideByZero(num1, num2);
}
catch (FirstDivideByZeroException)
{
Console.WriteLine("first number is zero");
}
I need that, FirstDivideByZeroException class will handle that Exeption instead of DevideByZeroExeption.
I tried to do that:
public class
FirstDivideByZeroException : DivideByZeroException {}
but when i run the application, that message appear:
"An unhandled exception of type 'System.DivideByZeroException' occurred .."
How can i implement that?
Loading
sudheer panwarPosted Jan 31, 2006, 6:24 AM
try
{
try{
DivideByZero(num1,num2);
}
catch(DivideByZeroException ex){
throw new CustomDivideByZeroException("Custom error :: " + ex.Message);}
}
catch(CustomDivideByZeroException exx){
MessageBox.Show(exx.Message);
}
*****
public
class CustomDivideByZeroException:System.Exception{
public CustomDivideByZeroException():base(){}
public CustomDivideByZeroException(string message):base(message){}
public CustomDivideByZeroException(string message , Exception ex):base(message,ex){
}
}
if anybody know better solution plz post it here.