October 07, 2007

Try..Catch...Finally....

try
{
int i = 4;
int j = 0;
int k = 0;

k = i / j;
}
catch (Exception)
{ }
catch (DivideByZeroException)
{ }
finally
{ }

This will give compile time error :: Error 1 A previous catch clause already catches all exceptions of this or of a super type ('System.Exception') ;


try
{
int i = 4;
int j = 0;
int k = 0;

k = i / j;
}

catch (DivideByZeroException)
{ }
catch (Exception)
{ }
finally
{ }

No Error;

No comments: