Tech Off Post

Single Post Permalink

View Thread: Rich Text Box Font
  • User profile image

    Jorgie wrote:
    The New method takes care of creating an instance of an object by allocating memory and any other resources needed by the object. If I am not mistaken, the opposite of New in managed code is Dispose, but you don't have to worry about directly calling Dispose most of the time, as the runtime will call the object's Dispose method when it is no longer needed.

    Dispose is only used by IDisposable for unmanaged resources used by managed classes. Whilst managed code has destructors, these are always called by the GC and not the user. Unlike C++ where you needed to call delete every time you called new, the CLR GC does this at the next GC interval once an object has no references to it.