Click here to Skip to main content
15,912,207 members
Home / Discussions / C#
   

C#

 
AnswerRe: Bitmap Vs Image Pin
Stefan Troschuetz10-Feb-07 4:53
Stefan Troschuetz10-Feb-07 4:53 
AnswerRe: Bitmap Vs Image Pin
ali_reza_zareian10-Feb-07 10:59
ali_reza_zareian10-Feb-07 10:59 
QuestionForm's distructor not called upon close... Pin
Shy Agam10-Feb-07 3:57
Shy Agam10-Feb-07 3:57 
AnswerRe: Form's distructor not called upon close... Pin
Guffa10-Feb-07 4:04
Guffa10-Feb-07 4:04 
GeneralRe: Form's distructor not called upon close... Pin
Shy Agam10-Feb-07 4:25
Shy Agam10-Feb-07 4:25 
GeneralRe: Form's distructor not called upon close... Pin
Scott Dorman10-Feb-07 4:53
professionalScott Dorman10-Feb-07 4:53 
GeneralRe: Form's distructor not called upon close... Pin
Shy Agam10-Feb-07 4:59
Shy Agam10-Feb-07 4:59 
GeneralRe: Form's distructor not called upon close... Pin
Colin Angus Mackay10-Feb-07 5:00
Colin Angus Mackay10-Feb-07 5:00 
shyagam wrote:
Should I use distructors?


You might want to re-read what Guffa said. He explicitly said there were no destructors in .NET. There are Finalizers which are similar, but not quite the same thing.

If your class holds onto any large amounts of memory, or unmanaged resources or any class that does then you should implement the IDisposable interface. In the Dispose method you release the memory, or the unmanaged resource or dispose the class. In the finaliser method you call Dispose - but that is a last resort. You should not really allow the finaliser to be called at all as it is inefficient. Normally you should Dispose of any object that implements the IDisposable interface.


shyagam wrote:
And what about non-form classes?


Any object of a class that implements IDisposable.


shyagam wrote:
Or maybe leave the destructors out, and keep my Dispose() implementations?


Keep the finalisers (not destructors). They call Dispose(). The Dispose method does the clear up. You keep the finaliser as a safety mechanism in case the call to Dispose was forgotten about.


GeneralRe: Form's distructor not called upon close... Pin
Shy Agam10-Feb-07 5:04
Shy Agam10-Feb-07 5:04 
GeneralRe: Form's distructor not called upon close... Pin
Guffa10-Feb-07 5:51
Guffa10-Feb-07 5:51 
AnswerRe: Form's distructor not called upon close... Pin
PIEBALDconsult10-Feb-07 15:14
mvePIEBALDconsult10-Feb-07 15:14 
GeneralRe: Form's distructor not called upon close... Pin
Shy Agam10-Feb-07 20:34
Shy Agam10-Feb-07 20:34 
QuestionShutdown Pc from withing code! Pin
Hussam Fattahi10-Feb-07 3:06
Hussam Fattahi10-Feb-07 3:06 
AnswerRe: Shutdown Pc from withing code! Pin
M Harris10-Feb-07 3:15
M Harris10-Feb-07 3:15 
QuestionParameter value '2.3333333333333333333333333333' is out of range Pin
Nafiseh Salmani10-Feb-07 0:38
Nafiseh Salmani10-Feb-07 0:38 
AnswerRe: Parameter value '2.3333333333333333333333333333' is out of range Pin
Colin Angus Mackay10-Feb-07 1:08
Colin Angus Mackay10-Feb-07 1:08 
QuestionWindows Service Pin
Syed Shahid Hussain10-Feb-07 0:15
Syed Shahid Hussain10-Feb-07 0:15 
AnswerRe: Windows Service Pin
Michael P Butler10-Feb-07 1:25
Michael P Butler10-Feb-07 1:25 
GeneralRe: Windows Service Pin
Syed Shahid Hussain11-Feb-07 17:30
Syed Shahid Hussain11-Feb-07 17:30 
AnswerRe: Windows Service Pin
Dave Kreskowiak10-Feb-07 4:09
mveDave Kreskowiak10-Feb-07 4:09 
GeneralRe: Windows Service Pin
Syed Shahid Hussain11-Feb-07 17:32
Syed Shahid Hussain11-Feb-07 17:32 
GeneralRe: Windows Service Pin
Dave Kreskowiak12-Feb-07 2:22
mveDave Kreskowiak12-Feb-07 2:22 
GeneralRe: Windows Service Pin
Syed Shahid Hussain12-Feb-07 17:22
Syed Shahid Hussain12-Feb-07 17:22 
QuestionDistance CAlculator Pin
Shriya Kapoor10-Feb-07 0:09
Shriya Kapoor10-Feb-07 0:09 
AnswerRe: Distance CAlculator Pin
Colin Angus Mackay10-Feb-07 0:27
Colin Angus Mackay10-Feb-07 0:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.