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
Why interface is required?
What is the difference between field and property in c#?
Explain types of comment in c# with examples
Where is the main method in c#?
what is c# command?
What is public, private, protected, internal and internal protected?
Explain boxing and unboxing in c#?
What is the object class in c#?
What is difference between string and string builder?
How do you convert byte array to hexadecimal string, and vice versa?
How we can create an array with non-default values?
What are the types of parameters in c#?
Why do I get a "cs5001: does not have an entry point defined" error when compiling?
how to insert the data from the grid view to database table though button click.pls send the answer to mail id suri1319@gmail.com
What is the difference between throw and throw ex?