我有两个类,比如 classMyFirstClass
和MyAnotherClass
,MyAnotherClass
正在实现 IDiposable 接口。
public class MyFirstClass
{
public string xyz{get;set;} ..... and so on
}
public class MyAnotherClass : IDisposable
{
private readonly MyFirstClass objFc = new MyFirstClass();
public static void MyStaticMethod()
{
var objOfFirstClass = new MyFirstClass();
// something with above object
}
public void MyNonStaticMethod()
{
// do something with objFc
}
#region Implementation of IDisposable
.... my implementations
#endregion
}
现在我还有一堂课,我正在打电话MyAnotherClass
,像这样
using(var anotherObj = new MyAnotherClass())
{
// call both static and non static methods here, just for sake of example.
// some pretty cool stuffs goes here... :)
}
所以我想知道,我应该担心我的对象的清理场景吗?另外,我的ObjFC
(内部非静态)和objOfFirstClass
(内部静态)会发生什么。
AFAIK,使用将照顾一切......但我需要知道更多......