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
Can we inherit static class in c#?
Why do we need nullable types in c#?
What is event delegate in c#?
What is the difference between abstract and virtual?
Explain more on CLR
What is mean by c#?
Explain “static” keyword in c#?
In .NET which is the smallest unit of execution?
What does protected internal access modifier mean?
How do you create empty strings in c#?
Are arrays value types or reference types?
How do I simulate optional parameters to com calls?
What is xml document how do you open it?
What is difference between Trace and Debug
can you allow a class to be inherited, but prevent the method from being over-ridden?