C# Interview Questions and Answers
<< Previous Question Next Question >>
 Question: 199 Page Views: 

Having the following code:- class main { public static void Main() { try { Console.WriteLine(\"Try block\"); return; } finally { Console.WriteLine(\"Finally block\"); } } } Now the question is if return from a try block, does the code in the finally block will execute?



Posted By: Avi Date: 1 October 2010 11:27:31 AM
 Answer:

Yes. It is because that the code in the finally block always executes even the try block is executed or not.


Posted By: avibtech


Date: 1 October 2010 11:27:31 AM
Post a better Answer if you have
 
(Will show your Gravatar icon)  
  Country flag

Loading
Enter the text as shown in the image XDKZCN
Related Questions
C# : Is there any way tp prevent a class being inherited , so that it can't act as a base class to some other class?

Is there any way tp prevent a class being inherited , so that it can't act as a base class to some o....

Yes, it is possible. This can be done with the help of the sealed keyword. It can be done as follows....
Category: C# Date: 10/1/2010 11:37:31 AM
C# : Why an error occurs when one tries to declare a method without specify its return type?

Why an error occurs when one tries to declare a method without specify its return type?

If the return type is not included at the time of declaration of the method, the compiler thinks it ....
Category: C# Date: 10/1/2010 11:36:31 AM
C# : In one Try block what is the need of multiple  Catch Blocks?

In one Try block what is the need of multiple Catch Blocks?

If there is one catch block in the try block then it will catch every exception but it will not be c....
Category: C# Date: 10/1/2010 11:35:31 AM
C# : Write the syntax of calling an overloaded constructor within a constructor?

Write the syntax of calling an overloaded constructor within a constructor?

Syntax:- class sum1 { sum1(int count) { } } class sum0 : sum1 { sum0() : sum1(2) // calling bas....
Category: C# Date: 10/1/2010 11:34:31 AM
C# : Write the difference between TypeOf and GetType?

Write the difference between TypeOf and GetType?

Both of them produce the same information. The difference lies that from where the information is go....
Category: C# Date: 10/1/2010 11:33:31 AM