Destructor question!!!

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Sep 2007
Posts: 73
Reputation: MxDev has a little shameless behaviour in the past 
Solved Threads: 2
MxDev MxDev is offline Offline
Junior Poster in Training

Destructor question!!!

 
0
  #1
Sep 30th, 2009
Hi guys,

Is it necessary to use destructor in c# to terminate any created objects??

Thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,668
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 476
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: Destructor question!!!

 
0
  #2
Sep 30th, 2009
Destructor is a very special method of class and it is used to implement object specific cleanup code. Unreferenced objects are released by the Garbage collector.
Last edited by adatapost; Sep 30th, 2009 at 11:34 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 927
Reputation: DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough 
Solved Threads: 150
DdoubleD DdoubleD is offline Offline
Posting Shark

Re: Destructor question!!!

 
0
  #3
Sep 30th, 2009
MSDN:
The programmer has no control over when the destructor is called because this is determined by the garbage collector. The garbage collector checks for objects that are no longer being used by the application. If it considers an object eligible for destruction, it calls the destructor (if any) and reclaims the memory used to store the object. Destructors are also called when the program exits.
Take a look at these:
Destructors
Dispose
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,283
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 583
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Destructor question!!!

 
0
  #4
Sep 30th, 2009
The links DdoubleD posted should explain it, and more than likely if you're asking that question then you don't need a finalizer. The finalizer/destructor gives you one more chance to free up unmanaged resources so they're not leaked.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC