Instantiating a class in .NET

  • Thread starter Thread starter Carl
  • Start date Start date
C

Carl

Hi,

I have a class in .Net which I instantiate in my code
behind on one of my aspx pages.

When I am finished with the instance, what is teh best
method of taking it out of memory. Should I set it to
nothing or can I dispose of it?

Thanks,
Carl.
 
Carl said:
I have a class in .Net which I instantiate in my code
behind on one of my aspx pages.

When I am finished with the instance, what is teh best
method of taking it out of memory. Should I set it to
nothing or can I dispose of it?

Just make sure there are no live references to the object, and it'll be
garbage collected in time. If there are unmanaged resources (file
handles etc) directly or indirectly "inside" the object, you should
probably dispose of those explicitly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top