Can two catch blocks be executed?
Answers were Sorted based on User's Feedback
Answer / gyana
NO,we cannot use two catch block.It can't be executed.
| Is This Answer Correct ? | 2 Yes | 3 No |
Answer / guest
yes. not only 2 catch blocks but 'N' number of catch blocks
associated with respective try block can be executed.
| Is This Answer Correct ? | 1 Yes | 7 No |
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 |
What namespaces are necessary to create a localized application?
2 Answers Rolta, Siebel Systems, Visual Soft,
What are the important concepts in OOPS
The int maps to which C# keyword in .NET type?
Can you describe iuknown interface in short?
What are the differences between events and delegates in c#?
Can a structure inherit a class.
How many aware interfaces are there?
What is the difference between method and function in c#?
What is the main purpose of linq?
how to implement a web service in .net
what are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?
Explain the accessibility modifier protected internal?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)