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

Do unused Namespaces in c# affect run-time performance?

1036


What is difference between code access and role based security?

1075


What is difference between events and delegates?

938


What do you mean by sealed classes and static classes?

994


How can I create a process that is running a supplied native executable (e.g., Cmd.exe)?

1093


Are objects passed by reference in c#?

993


What language is c# similar to?

922


Can you prevent a class from being instantiated?

992


I wish to create a windows application to perform a similar function as that of the "Search" which is provided to look for related files and folders in the System.. What steps must i follow??

1925


What is data hiding in c#?

910


Is it possible to execute multiple catch block for a single try statement?

1063


Which of the following API is used to hide a window?

1029


What is session and cookies in c#?

965


Write a syntax for writing a event delegate.

946


Does c# support properties of array types?

926