The reason I ask - isn't the purpose of this construct to make sure the call to idisposable is accomplished when you want it to be?
>Sure it is. I think VB took it from C#
>
>>Is there a "Using" construct in C# like the one in VB ?
>>
>>>>Hi,
>>>>I initialize object to private vairable via
>>>>
>>>>public class MyBase
>>>>{
>>>>private MyClass _myClass = new MyClass();
>>>>}
>>>>
>>>>I found that it caused memory leak as it is not released. May I know how should I release it once myBase is released?
>>>
>>>As long as there are no longer any other references to that class the garbage collector will clean it up. However, garbage collection doesn't occur immediately. It can take quite a while for it to clean up. Since .NET uses a generational garbage collector the longer MyBase lives the longer it can take for the GC to clean up other references held. It can look like a memory leak when it really isn't.
Charles Hankey
Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy
Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.
-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin
Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.