C # differences between form close, dispose, and application. Exit ()

Source: Internet
Author: User

Close closes the form. The object still exists. You may need to use it again after calling the close function to release the resource.

Dispose: destroys an object. The form object is recycled, that is, it does not exist. The resources released by the dispose function are no longer used.

Application. Exit. EntireProgramWhen the process ends, all objects in the project are destroyed and the entire application is exited.

 

Note: It may vary with MDI. In this case, you need to manually call dispose to mark all controls of the form as garbage collection.

Close and dispose call exit to exit a single form.
The close call will trigger the wm_close message. If you add a few words in form_closingCodeTo block it. Set handle to false.
Dispose directly releases the entire object, that is, manually releases it .. Net is an automatic garbage collection mechanism. If you do not release it, it can also be released by the system. Manual release is also beneficial.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.