locked
Setting classes to nothing RRS feed

  • Question

  • User-454619676 posted

    Hi All

    This is my first post and my first forray in .net, previously I've only used VB6 and am loving .net!!

    I have made a website in ASP with VB and on the examples that I've seen classes that are used are not set to nothing. Is this not needed in .net?

    Thanks in advance!

    Thursday, March 24, 2011 1:13 PM

Answers

  • User-1360095595 posted

    It's not needed.  Garbage collection shields you from having to do anything.  Object that go out of scope will (eventually) be disposed when the GC runs.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 24, 2011 2:54 PM

All replies

  • User-1360095595 posted

    It's not needed.  Garbage collection shields you from having to do anything.  Object that go out of scope will (eventually) be disposed when the GC runs.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 24, 2011 2:54 PM
  • User1757172363 posted

    Careful with your terminology:  I think you are asking if you need to set an object to null when doing the following:

     

    Dim obj As SomeClass = Nothing

    The answer is no.  By default obj will be Nothing even if you didn't assign it.

     

    Thursday, March 24, 2011 2:57 PM