If an exception occurs inside a try block, then the control flow passes immediately to the next catch statement. When control flow passes to a catch block, the statements contained in the catch block are processed to handle the exception.
int SafeDivision(int x, int y)
return (x / y);
catch (System.DivideByZeroException dbz)
System.Console.WriteLine("Division by zero attempted!");
Asked In: Many Interviews |