Rathrola Prem Kumar
Can multiple catch blocks be executed?
By Rathrola Prem Kumar in .NET on Dec 17 2016
  • Rathrola Prem Kumar
    Dec, 2016 17

    No, Multiple catch blocks can’t be executed. Once the proper catch code executed, the control is transferred to the finally block and then the code that follows the finally block gets executed.

    • 1
  • Kaushik Dudhat
    Jul, 2019 9

    Yes

    you can use catch block with specific error type like
    1> for Divide By Zero Exception

    catch (DivideByZeroException) {
    Console.WriteLine(“Not possible to Divide by zero”);
    }

    2> fot Index Out Of Range Exception

    catch (IndexOutOfRangeException) { Console.WriteLine(“Index is Out of Range”);
    }

    you can put this both block below try block at a time.

    • 0
  • Mukesh Kumar
    Aug, 2017 31

    Yes you can use multiple catch but one try

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS