1、private System.ComponentModel.Container components = null是什么意思? 2、protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } 請高手解答,最好每一句都解答一下,本人是初學(xué)者 不懂
2 回答

ITMISS
TA貢獻(xiàn)1871條經(jīng)驗 獲得超8個贊
首先說,Dispose是關(guān)閉對象并釋放所使用的資源的方法。
// 定義了一個私有成員components,初始化值為null
1、private System.ComponentModel.Container components = null是什么意思?
// 重載了方法Dispose
2、protected override void Dispose( bool disposing )
{
if( disposing ) // 當(dāng)參數(shù)disposing是true時,
{
if (components != null) // 如果components不是null,就調(diào)components本身的Dispose方法
{
components.Dispose();
}
}
base.Dispose( disposing ); // 調(diào)用基類的Dispose方法
}
- 2 回答
- 0 關(guān)注
- 649 瀏覽
添加回答
舉報
0/150
提交
取消