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 the default value of singleordefault?
Why var is used in c#?
Why do we use 0?
What is the use of delegate?
What is the purpose of abstract class in c#?
Define satellite Assembly?
What are the different types of classes in c#?
What is array class in c#?
What is cookies in c# asp net?
How does inheritance work in c#?
What is func delegate in c#?
Is c# code is managed or unmanaged code?
What is default constructor c#?
What are the types of assembly available
What do you mean by serialization in .NET?