Answer Posted / shadab alam
yes two catch block can be executed .
Sorry for privious Error!whrer two catch block are not
executd but this time it has been executed
Now This is right answer here two
using System;
class a
{
public static void Main()
{
int a=8;
int b=0;
int [] arr=new int[]{1,2};
try
{
Console.WriteLine(a/b);
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
Console.WriteLine("Hello");
}
finally
{ try
{
Console.WriteLine(arr[2]);
}
catch(IndexOutOfRangeException d)
{
Console.WriteLine(d.ToString
()+ "hello");
Console.WriteLine("Hello");
}
}
}
}
output will be
----------------
System.DivideByZeroException: Attempted to divide by zero.
at a.Main()
Hello
System.IndexOutOfRangeException: Index was outside the
bounds of the array.
at a.Main()hello
Hello
| Is This Answer Correct ? | 12 Yes | 3 No |
Post New Answer View All Answers
How do I stop my console from closing in c#?
Illustrate the differences between the system.array.copyto() and system.array.clone()?
Can an array be null c#?
How do I make a dll in c#?
Explain deadlock?
What is clr in c#?
What is the object class in c#?
Can struct be static in c#?
Explain attributes in c#?
Can you use foreach iteration on arrays in c#?
Why do we need generics?
What is managed code?
How do I register my code for use by classic com clients?
What is action in c# 3.5?
What is .cshtml file?