tags:

views:

35

answers:

2
 public string GetSomething()
        { var a = String.Empty; 

            try 
            {
               // loop through the datareader 

                return "some data"; 
            }

            finally
            {
                reader.close(); 
            }

            return whatever; 
        }
A: 

Code in a finally block always runs. See here.

Matthew Jones
+2  A: 

The code in the finally block will get executed. You may want to call reader.dispose(). I like to use the using{} statement myself.

Gratzy
+1 for using using
Aidan

related questions