Will a using block close a database connection?

前端 未结 4 423
伪装坚强ぢ
伪装坚强ぢ 2020-12-03 04:07
using (DbConnection conn = new DbConnection())
{
    // do stuff with database
}

Will the using block call conn.Close()?<

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-03 04:49

    surely yes because it will dispose the connection and before disposing the inner logic of the connection calls the close.

提交回复
热议问题