by Christophe via Christophe on 5/11/2008 6:17:34 PM
I had to take over a project last week, an ASP.NET application. I found a lot of mistakes regarding resources protection and the use of try/catch/finally block. For instance, I found that:
SqlConnection con = new SqlConnection()try{ con.Open(); // Some code here}catch (Exception ex){ throw ex;}finally{ if (con != null) con.close();}
SqlConnection con = new SqlConnection()con.Open();try{ // Some code here}finally{ con.Close();}
using (SqlConnection con = new SqlConnection()){ // Some code here}
Original Post: try/catch/finally and resource protection: mistakes to avoid
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.