473,409 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

dispose and nothing? whats the main difference?

greetings,
should i do this

obj.dispose

then

obj = nothing

both does the same thing right? whats the core difference?
Nov 18 '05 #1
2 1810
"Asha" <As**@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
greetings,
should i do this

obj.dispose

then

obj = nothing

both does the same thing right? whats the core difference?


No. obj = nothing doesn't do anything anymore. It simply removes one
reference to the object. If that's the last reference to the object, then
the object may eventually be garbage-collected.

Dispose cleans up whatever the object thinks needs to be cleaned up, and
does it immediately.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #2
On Tue, 13 Jul 2004 21:37:01 -0700, Saravanan Durai <Saravanan
Du***@discussions.microsoft.com> wrote:
Dispose method is used to clean up the unwanted resources like sqlconnections,command objects,

dispose method will be called automatically if we create the instance in the following way

using ( DBreader reader=sp.executereader)
{

}

if DBreader is implemented idisposable interface then dispose method will be called
automatically at the end of scope,

In fact, the only objects you can put inside a using clause are
objects implementing IDisposable!

--s
--
Scott
http://www.OdeToCode.com
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Ken Durden | last post by:
I am in search of a comprehensive methodology of using these two object cleanup approaches to get rid of a number of bugs, unpleasantries, and cleanup-ordering issues we currently have in our...
17
by: Bob Lehmann | last post by:
Hi, My understanding is that Dispose() should not be used for destroying a connection object, and that Close() is preferred. However, in one of MS's Quickstart Apps I see this being used.... ...
19
by: Nathan | last post by:
I know this has been asked previously, but I've run into a situation where I need to know the difference between close and dispose, and I can't get the information I need from msdn help or previous...
6
by: Teresa | last post by:
1) If I do want to keep an object alive throughout the live of an application, how can I ensure that the GC doesn't clean it up? 2a) How do I determine if an object is a managed or an unmanged...
156
by: Dennis | last post by:
Ok, I'm trying to dispose of every object that I create that has a dispose method based on advice from this newsgroup. However, I'm not sure how to dispose of the following object that was created...
7
by: N! Xau | last post by:
Hello everybody, I am kind of a newbie. What's the difference between using dispose() or = nothing in the 'finally' block of the following code: Dim mycmd As New OracleCommand(setta_cmdQuery,...
71
by: active | last post by:
In the main program I check to see if a certain form has been disposed. Does it make sense in that form's FormClosed event to do: Me.Dispose to make sure it is disposed the next time I check. Or...
44
by: Smokey Grindle | last post by:
I have a list box on my form, but I need to databind it to a data table that is a private member of the form's class... so I basically have Public Class MyForm priate m_MyTable as new datatable...
3
by: sezanawa | last post by:
Hi Guys, I have a small application which i wrote in Java. There is a MainFrame extends jfram class. There is another class named LoginDialog extends JDialog. My MainFrame class have main...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.