News for hackers. Stuff that matters.
Re:Twenty years of C# with Anders Hejlsberg [audio] by giaour on Friday February 11, 2022 @08:40AM (#30301321)
> Regarding context managers I would need to come back to this post, as I don’t think IDisposable is capable of solving the same use cases, but it’s not on top of my mind as to why.

I'm definitely not as fluent in python as I am in c#, but don't context managers just allow you to define an __enter__ and __exit__ methods that are called when a `with` block begins and ends, respectively? That closely aligns to defining a constructor and .close() method on an IDisposable class, then creating an instance with a `using` statement.

There are no comments on this comment yet.