Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / January 2008

Tip: Looking for answers? Try searching our database.

Classes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keon - 11 Jan 2008 16:40 GMT
When you create an instance of a class, do you have to delete the
instance after you are finished with it?  I can't seem to find any
information dealing with that.  All I see is create the instance and
thats it.

Thanks

Keon
Ignacio Machin ( .NET/ C# MVP ) - 11 Jan 2008 17:12 GMT
Hi,

In general no, the GC will take care of that. The only difference is when
the class implement the IDisposable interface, these are classes that you
should call Dispose on when finished with them.

Signature

Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.

> When you create an instance of a class, do you have to delete the
> instance after you are finished with it?  I can't seem to find any
[quoted text clipped - 4 lines]
>
> Keon
Michael Starberg - 11 Jan 2008 17:38 GMT
> When you create an instance of a class, do you have to delete the
> instance after you are finished with it?  I can't seem to find any
[quoted text clipped - 4 lines]
>
> Keon

This is a very important and interesting question.
From the annals and history of computing,
memory allocation comes in different flavors.

1. Direct allocation. (remember malloc(int), anyone? *s*)
2. Reference Counting (The horrors of COM and IUnknown *s*)
3. Garbage Collecting (meow!)
4. GC + IDisposable (meow?)

Typically in .NET,  all your references are fire-and-forget.

But not always. You really need to learn about reference types (classes) and
value types (structs) and why the latter is never/can't be Garbage
Collected.

Then you really must understand the IDisposable.Dispose() method and its
use. And the C# syntactic suggar using using.

Sit Vis Nobiscum
- Michael Starberg

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.