C# has the using-statement + IDisposable which is similar context managers in python (except no __enter__).
C#8 then allowed using-statements that do not require blocks, which then are disposed when leaving the current block.
Pre C#8, you had to have a block, similar to how with-statement requires a block aka indentation
using (var res = OpenSomeResource()) {
res.doSomething();
// res.Dispose() implicitly called
}
Now you can have this (which is a bit like a go-style Defer but for blocks) using var res = OpenSomeResource();
res.doSomething();
// res.Dispose() implicitly called at end of current block
Of course, you have to take the potentially longer lifetime into account. This way looks a lot like C++s RAII with constructors and destructors (except the destructor here is the IDisposible.Dispose implementation).