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

How big is a float?

860


Can destructors have access modifiers?

906


if a method is marked as protected internal who can access it?

981


Differentiate between dataset and datareader?

911


State whether it is true to test a Web service you must create a windows application or Web application to consume this service or not?

882


What does exclamation mark mean in access query?

934


How big is a 64 bit integer?

841


What is the difference between struct and class in c#?

1147


how to print invert pyramid in c#

1707


Can bool be null c#?

835


Can a static class have a constructor c#?

856


is it possible to access a remote web service Without UDDI?

958


Explain the use of SN.exe

1031


Write one code example for compile time binding and one for run time binding? What is early/late binding?

982


What is the resgen.exe tool used for?

931