1 protected void Page_Load(object sender, EventArgs e)
2         {
3 
4             using (SqlConnection conn=new SqlConnection())
5             {
6                 //do some thing
7             }
8            
9         }

IL查看:
探究using实现IDisposable的本质
从图中可以看出:是在try{}finally{}中实现。IDisposable是对非托管资源释放,using真正实现的Dispose()是放在finally中实现。

相关文章:

  • 2021-11-07
  • 2021-05-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-03
  • 2022-12-23
猜你喜欢
  • 2021-10-22
  • 2022-03-03
  • 2021-04-30
  • 2021-08-12
  • 2022-12-23
相关资源
相似解决方案