Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

C#'s 'using' statements allow this kind of pattern for types implementing IDisposable. It looks something like this (might be a little off):

    using (var file = File.Open("foo.txt"))
    {
        ...
    }


This is what I thought of immediately except to implement the end with behavior you have to override the IDisposable shut down sequence? (does that make sense?)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: