Will a using block close a database connection?

前端 未结 4 428
伪装坚强ぢ
伪装坚强ぢ 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 05:01

    Yes, it will; the implementation of DbConnection.Dispose() calls Close() (and so do its derived implementations).

提交回复
热议问题