Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8377835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:46:26+00:00 2026-06-09T15:46:26+00:00

Read some code from a legecy system. Say I have a instance of class

  • 0

Read some code from a legecy system.

Say I have a instance of class A, then added it to a collection, then dispose it.

I just can not understand what’s the point to use implicit dispose here since the code still use the myControlCollcetion,which means the cltCheckBoxA wont be really freed anyway.

Why?

using (UserControlA cltCheckBoxA = new UserControlA())
{
    //some operation
    base.myControlCollcetion.Add(cltCheckBoxA);
}

//Other operation against myControlCollcetion
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:46:28+00:00Added an answer on June 9, 2026 at 3:46 pm

    Disposing an object is entirely different from freeing it’s managed memory (which is what the GC does). Dispose is explicitly cleaning up all unmanaged resources that the garbage collector can’t free.

    This means that when the object is used after Dispose is called on it there are a lot of possibilities. (This is not an exhaustive list.)

    1. Many objects are essentially unusable once their unmanaged resources are cleaned up. In this case, it’s common for them to throw an exception whenever one of their members is accessed.
    2. The object could just act in an unexpected manor because it is being used after it is disposed. It might result in weird exceptions, or just incorrect results from methods, or, really, anything.
    3. It may never have actually had unmanaged resources. Some objects implement IDisposable just so that they are more extensible, or to try to future-proof them. DataTable is an example of this; it’s Dispose does nothing. In this case, the object will work just fine after it is disposed.
    4. It’s possible that the object is still usable even without its unmanaged resources. Maybe only a portion of it’s functionality becomes unusable after Dispose is called, in which case as long as only those limited aspects are used later on it will work just fine.
    5. Some object might re-create it’s unmanaged resources when accessed after it is disposed. It would be bad practice, but it’s your class you can do what you want.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just read some source code is from org.apache.cxf.common.logging.JDKBugHacks and also in http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java .
I have the following function from some legacy code that I am maintaining. long
I need to read some Scala code (starting from a few hours ago), I
I want to read some code from a file and give this to a
I have some code from my VB.NET 1.1 days that allowed me to dynamically
Yesterday I read some code of a colleague and came across this: class a_class
I have written some code in C to read a binary file containing complex
I read code from one book and have this method: public int getScore(String name)
I have some code from the net reading hyperspectral data (image, so lots of
I am converting some code from Perl into .NET. I have this s/// pattern

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.