C # GC

Source: Internet
Author: User

 Public classtestclass:system.idisposable{//Dispose method for programmers to explicitly invoke     Public voidDispose () {//call the Dispose method with parameters to release both managed and unmanaged resourcesDispose (true); //When you manually call Dispose to release the resource, the destructor is unnecessary, which prevents the GC from calling the destructorSystem.GC.SuppressFinalize ( This); }    //the Dispose method of protected is guaranteed not to be called externally. //Pass in bool value disposing to determine whether to release managed resources    protected voidDispose (BOOLdisposing) {        if(disposing) {///TODO: Add the code that cleans up "managed resources" here, it should be xxx. Dispose ();        }        ///TODO: Add code to clean up "unmanaged resources" here    }    //destructors for GC calls~TestClass () {Dispose (false);//Releasing unmanaged Resources    }}

C # GC

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.