explicit deletion of object
-
is there any method to delete an object in c# explicitly or i have to set obeject to null and then wait for GC to delete it.v skhurram
-
is there any method to delete an object in c# explicitly or i have to set obeject to null and then wait for GC to delete it.v skhurram
-
There really is no 'Explicit' deletion of managed objects in .net like there are in other languages such as c++. You will have to always wait for th GC to do it stuff. obj.Dispose is just a clean up method really designed for releasing unmanged resources like handles. The Dispose Pattern discusses disposing of objects
Keep your eyes open, you might spot alternatives.
-
is there any method to delete an object in c# explicitly or i have to set obeject to null and then wait for GC to delete it.v skhurram
There is no way to "delete" an object in .NET like you do in C or C++. The closest you can get is to call the
Dispose
method if it's available (or the appropriate equivalent since some classes have aClose
method that actualy does the same work asDispose
) and wait for the GC to delete it. Check out this article Implementing IDisposable and the Dispose Pattern Properly[^] for more details on how to useDisopse
.----------------------------- In just two days, tomorrow will be yesterday. http://geekswithblogs.net/sdorman