Dispose a Class?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do you dispose of an user defined external class (CS file) after youve
finished using it? Ive tried IDispose but i feel I may not be using it
correctly.
 
I'm not sure I understand you correctly when you say "a user defined
external class", do you mean this an instance of an object which class is
defined in another assembly ?

If you own the object and you want to dispose it, you must ask for
IDisposable and call Dispose on it.

Note that if somebody is keeping a reference to this object besides you, you
will cause it to fail, for example, if a Font object is passed to you this
Font object may have also been passed to other controls, so disposing it
will not be advised here unless you know that all of the other controls are
also being disposed, calling Dispose multiple times is ok, using an object
after it is disposed (for example trying to draw a text with a disposed
Font) is not.
 
Back
Top