Arjen,
IDisposable is used to indicate when an instance should release some
resource that is expensive. Almost all of the time, this is in reference to
something like a file handle, a socket, a database connection, or something
like that. It doesn't do anything to indicate that the object will exist
anymore in memory.
You can't control when the object is released from memory, that's what
the GC is for.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Arjen" <bo*****@hotmail.com> wrote in message
news:dd**********@news4.zwoll1.ov.home.nl...
Hi,
Here I have made some sample code.
I want to know if I'm using IDisposable on the right way.
public class Person {
public string name;
public string address;
}
public class main {
try {
Person person = new Person();
person.name = "Arjen";
}
catch{
throw;
}
finally{
((IDisposable)person).Dispose();
}
}
Is the IDisposable useful here?
(I want that the object don't exist any more in the memory)
Thanks!