Skip to content

Create disposal function

CodingUnit edited this page Apr 11, 2012 · 6 revisions

Create disposal function

  • Category: Disposal

  • Description: Create disposal function

  • Comment: For use this example you must include NewObjectMacro.dll reference (from Nemerle program directory)

  • Code:

 using System; 
 using System.Console; 
 using Nemerle; 
 using Snippets;

def DisposalSample2() 
{
    def disposed() { WriteLine("disposed") }
    def disposable = newobj { IDisposable : { Dispose = disposed } };
         
    using (disposable) 
      WriteLine("inside");

    WriteLine("finished");
}

DisposalSample2() 
  • Execution Result:
 inside 
 disposed 
 finished 

[Copyright ©](Terms of use, legal notice)

Clone this wiki locally