What is the difference between these statements
obj=null and obj.dispose()

Answer Posted / kishoreg

This is not a good and safe practice to call a Dispose.
In "Dot Net" it is automatically handle by Garbage
collection. It is the responsibility of GC to call the
Dispose and clear the memory.. but it is not sure that when
GC will call the Dispose.

so in that case we can forcefuly call it.

Consider one case when we forcefully destroy the object and
after some time i will try to use the same object at that
time u will get the error msg.

so better to object = null;

other material:
http://blogs.msdn.com/irenak/archive/2006/10/05/SYSK-
212_3A00_--Does-.NET-Garbage-Collector-call-Dispose_3F00_--
Dispose-_1320_-Best-Practices_2E00_.aspx

Is This Answer Correct ?    4 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the .net datatype that allows the retrieval of data by a unique key?

704


Can interface have virtual methods in c#?

687


How do I declare a pure virtual function in c#?

779


Which are the access modifiers available in c#?

742


What is a deadlock lock?

720


What is arraylist c#?

683


What is the base class in .net from which all the classes are derived from?

759


What is private class in c#?

694


explain the three services model commonly know as a three-tier application.

766


What is meaning of type safety in c#?

669


Define clr in .net?

774


Are tuples mutable c#?

691


What is datagridview in c#?

868


What is dictionary class in c#?

691


Which types of inheritances does c# support?

685