locked
Best practice RRS feed

  • Question

  • Hi.

    I want to know what the BEST practice is for doing this. I do know from my own experience/learnment BUT I want to know, for .NET 2.0 (if there is...) a better way/best practice:

    Lets say you have an array. You have items stored in this array.

    when you have finished dealing with this temp array, for example, is it best to REMOVE all the contents in the array THEN make it null? or is it best to just make the array null even if there are objects in this array?

    Which is the best answer?
    Friday, December 9, 2005 10:41 PM

Answers

  • Unless the items in the array are Dispose:able, you shouldn't have to worry about removing them. The garbage collect will find 'em just fine...

    If the items are Dispose:able, and the only reference you have to them is through the array, you should go through and dispose them before you let go of the Array (just as you would with any other dispose:able object that you no longer need)

    Best regards,
    Johan Stenberg
    Saturday, December 10, 2005 2:11 AM

All replies

  • Unless the items in the array are Dispose:able, you shouldn't have to worry about removing them. The garbage collect will find 'em just fine...

    If the items are Dispose:able, and the only reference you have to them is through the array, you should go through and dispose them before you let go of the Array (just as you would with any other dispose:able object that you no longer need)

    Best regards,
    Johan Stenberg
    Saturday, December 10, 2005 2:11 AM
  • kewl! Thanks for that ;-)
    Saturday, December 10, 2005 2:23 AM