usingMSDN - using Statement (C# Reference)
축약형일 뿐이다.
class CA : IDisposable { public void DoSomething() { } public void Dispose() { } } class CB { void Method() { using (CA a = new CA()) { a.DoSomething() } } }
위 코드는 다음과 같이 확장된다.
class CA : IDisposable { public void DoSomething() { } public void Dispose() { } } class CB { void Method() { { CA a = new CA(); try { a.DoSomething() } finally { if (a != null) ((IDisposable)a).Dispose(); } } } }
당연히 using 안에 들어가는 녀석은 IDisposable을 구현해야만 한다.
see also C# CDisposable, C# GarbageCollection
-- 2010-07-28
Similar pages by cosine similarity. Words after page name are term frequency.