Re: Disposing by reflection?



Steven Wolf <apoc69@xxxxxxx> wrote:
> I like to implement IDisposable in my classes

In all of them? That's a waste of time.

> but at a certain point its becoming boring when i have to take care about
> setting all members in a class to null..sometimes i forgot that also..
>
> but i could avoid that, by using reflection..just iterating thru all local
> members and set them null, but i guess this would slow down the code..

You don't need to set everything to null. It might *very occasionally*
help - if your class has references to objects in "younger"
generations, for example - but usually it's not particularly useful.

The important bit about IDisposable is to implement it when you have
unmanaged resources, or references to other objects which implement
IDisposable (and which you're responsible for).

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Disposing by reflection?
    ... but at a certain point its becoming boring when i have to take care about ... setting all members in a class to null..sometimes i forgot that also.. ... Prev by Date: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: The third instalment
    ... So far there have been two gay references this year (other than ... unrealistic - as Andrew likes to argue so stridently, most Christians ... I don't care about Cardiff. ...
    (rec.arts.drwho)
  • Re: Should we just turn out the lights?
    ... Anyone care to read this and see if we can come up with ways to save ... and it's a group that matters to us members. ... RMD needs such molding. ... be successful it HAS to HAVE such and such a form. ...
    (rec.motorcycles.dirt)
  • Re: [Full-Disclosure] UTTER HORSESHIT: [was January 15 is Personal Firewall Day, help the cause]
    ... > ever heard for not using security products. ... Many of the people on here care nothing about security, ... >> If Annie's weren't members of Administrators, ... >> Administrators would not have access to apps like IE and OE, ...
    (Full-Disclosure)
  • Re: WPD Waverly Tn July 28 2005
    ... > business to care who you bring into your home. ... Several members of the ... > defamation of character is a criminal offence. ...
    (alt.med.fibromyalgia)