Results 1 to 2 of 2

Thread: Exception handling????

Threaded View

  1. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Exception handling????

    Simply assign "null" to your variable and you'll have no issues, i.e. object obj = null;

    Edit:
    Be aware, though, that setting your object reference to null in the Finally block is still leaving things to the garbage collector. You are not actually disposing your object but simply removing all references to it. This just tells the garbage collector that it can clean up your object whenever it is ready. Unless your object doesn't go out of scope for some time after this section of code setting your variable to null does not really achieve anything, although it may still be good practice. If you want to free the resources held by your object you need to explicitly dispose it before setting your reference to null.
    Last edited by jmcilhinney; Jun 6th, 2005 at 11:16 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width