Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Can two catch blocks be executed?

Answer Posted / shadab alam

Yes Yes
Two catch block can be executed at one time.
The example is given bellow .

using System;
class ab
{


public static void Main()

{
int []arr=new int[2]{2,3};
int a=9;
int b=0;
try
{
int r=a/b;
}
catch(DivideByZeroException d)
{
Console.WriteLine(d.ToString());
}
catch(Exception aa)
{
Console.WriteLine(aa.ToString());
}
finally
{
Console.WriteLine(arr[3]);
}

}

}


output will be
-------------
System.DivideByZeroException: Attempted to divide by zero.
at ab.Main()

Unhandled Exception: System.IndexOutOfRangeException: Index
was outside the boun
ds of the array.
at ab.Main()

Is This Answer Correct ?    6 Yes 16 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are destructors in C#?

1555


Is it possible to inherit multiple interfaces?

1013


How do you pronounce c#?

910


What is the difference between double and decimal in c#?

966


How do I create a delegate/multicastdelegate?

1005


What is deadlock in c#?

945


How can I access the registry from c# code?

1018


How many bytes is a char c#?

896


What do you mean by sealed classes and static classes?

1003


What is a decimal c#?

869


What is the c# equivalent of c++ catch (…), which was a catch-all statement for any possible exception? Does c# support try-catch-finally blocks?

904


Is void a class?

874


Why do we use struct in c#?

968


Can you create an instance of a static class?

999


How do I do implement a assert?

972