SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Forums
SiteExperts.com Forums
All Discussions

SiteExperts Feedback
The Lounge
Dynamic HTML
Site Design/ Critiques
HTML and CSS
XML Technologies
The Wireless Internet
Internet Explorer
Microsoft .NET
The Server
Technical Support

Sponsored Links

User Groups : Forums : SiteExperts : Microsoft .NET :

Previous DiscussionNext Discussion
 Dispose() vs null
Ok, I hope some of the folks who used to post on here still do, and I hope you see this. I know this site has been overrun with spam lately, so that you guys don't come here much, but I have a serious C# question.

Ok, let's say I create a class in C# called MyClass

Now, let's say in a code-behind, I reference it like this:

MyClass objMC = new MyClass();

And then I do whatever I need to do with it.

When I'm done, I want the GC to clean it up.

What's the difference in using something like

objMC.Dispose();

versus

objMC = null;

I understand that to use Dispose() I have to add some additional code (including a destructor, ~MyClass) to the class itself.

But what's the "behind the scenes" difference, and which one is better to use?

Started By Monte on Dec 12, 2008 at 12:57:53 PM

15 Response(s) | Reply

View All Replies | Goto Page: 3 2 1
bod1467 on Dec 15, 2008 at 6:57:55 AM

http://www.devx.com/dotnet/Article/33167

http://www.csharphelp.com/archives3/archive571.html

Any help?


View All Replies | Goto Page: 3 2 1

To respond to a discussion, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password
Copyright 1997-2000 InsideDHTML.com, LLC. All rights reserved.