If we write a goto or a return statement in try and catch
block will the finally block execute?
Answer Posted / uday
The statements after goto in try block wont be executed.
And Finally block also get executed.
static void Main(string[] args)
{
int a, b,c;
a = 10;
b = 0;
try
{
goto A;
c = a + b;
Console.WriteLine(c);
}
catch (Exception e)
{
Console.WriteLine("In parent exception Catch" +
e.Message);
}
finally
{
Console.WriteLine("In finally block");
}
A:
Console.WriteLine("at goto label");
Console.Read();
}
The output is:
In finally block
at goto label
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is void method?
What is the wildcard character in sql?
Is arraylist thread safe?
What is a satellite assembly in c#?
What is the purpose of the integer parse method the decimal parse method?
Which constructor is called first in c#?
What is .edmx file?
Explain the role of Garbage collector and its generations?
What is the delegates in c#?
Explain the difference between class and interface in .net?
What are properties in C#?
What is use of FormBoarderStyle Propertie
What is difference between arraylist and list in c#?
Explain dataset.acceptchanges method in .net?
Can we inherit partial class in c#?