Dispose() and null

If I call the "Dispose" method on an object, would it be equal to null? And If I make the object equal to null instead, would it be same as calling "Dispose" method of the object?

For example:


SomeObject obj1 = SomeObject();
SomeObject obj2 = SomeObject();
obj1.Dispose();
obj2 =null;

Console.WriteLine(obj1 == obj2);

What would be the result of executing the above statements (suppose SomeObject only inhreits the default Dispose method)?

[708 byte] By [zheny.lu] at [2008-3-5]
# 1
Hi,

Dispose() method is usually found on objects that need to clean up some resources for example connections or file handles. In such cases, if you just set the object to null, the unmanaged resource such as a database connection is not released. So Dispose is not the same as null.

Also take a look at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconFinalizeDispose.asp

Regards,
Vikram

Vikram at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# Language...