M Rahman
Can I use multiple try and catch in a program using c#
By M Rahman in .NET on Apr 18 2018
  • Pankaj Gupta
    Mar, 2019 12

    You can use multiple catch block for one try block. but there can be only one try block for a single code block.

    • 1
  • Bidyasagar Mishra
    Jul, 2019 8

    we can try multiple try catch in a program but we can use one try catch for single code block

    • 0
  • Ivaylo Dimitrov
    Dec, 2018 3

    You can use multiple catch for one try statement and separately you can use as much as you need try catch blocks.

    • 0
  • M Rahman
    Apr, 2018 18

    class emp {static void Main(string[] args){Console.WriteLine("Enter 1st and 2nd Number");try{int a = int.Parse(Console.ReadLine());int b = int.Parse(Console.ReadLine());int c = a / b;int d=c+a*b Console.WriteLine( a, b, c,d);}catch(DivideByZeroException ex){LogError(ex);Console.Write("not divide by zero");}catch(InvalidOperationException ex){LogError(ex);Console.Write("Not a valid number.");}catch(FormatException ex){LogError(ex);Console.Write("Not a valid number. Please try again.");}Console.ReadLine();}}

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS