c#中的Dispose()

2025-05-13 12:38:43
推荐回答(3个)
回答1:

Dispose()销毁对象,垃圾回收机制。
using(SqlConnection conn = new SqlConnection(ConnStr))
{
这样写会自动垃圾回收。
}

回答2:

用using语句最好了。

回答3:

Using(SqlConnection conn = new SqlConnection(ConnStr))
{
封装了释放资源的方法

}