クラスとという2つのクラスがMyFirstClass
あり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
でいるクラスがもう1つあります。これは、次のようなものです。
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、使用するとすべてが処理されます...しかし、もっと知る必要があります...