1 回答

TA貢獻(xiàn)1946條經(jīng)驗 獲得超4個贊
確實是釋放資源啊。
你要看的話= = 那看吧
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
//然后gc 回收垃圾 gc 回收垃圾 要講就講的多了 自己去查文章吧
}
///this.Dispose(true); 調(diào)用這里
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
lock (this)
{
if ((this.site != null) && (this.site.Container != null))
{
this.site.Container.Remove(this);
}
if (this.events != null)
{
EventHandler handler = (EventHandler) this.events[EventDisposed];
if (handler != null)
{
handler(this, EventArgs.Empty);
}
}
}
}
}
其實 .net 這玩意兒 就是讓你在不了解
某些東西的情況下 任然能寫出質(zhì)量比較高的代碼, 比如內(nèi)存控制
當(dāng)然 了解才能更好的使用它。 所以這些東西 大概知道就行了,畢竟c# 重點并不是在這里
添加回答
舉報