class Program { int ret = default(int); static void Main(string[] args) { Program ob = new Program(); Console.WriteLine(ob.DoSomeOperation()); Console.WriteLine("------------------------------------"); //Console.WriteLine(ob.ret); Console.ReadKey(); } public int DoSomeOperation() { try { ret = 5; //return ret; } catch (Exception) { throw; } finally { ret = 9; } return ret; } }
Quote:If the return statement is inside a try block, the finally block, if one exists, will be executed before control returns to the calling method.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)