Is it theoretically possible to create a RAII-Wrapper for .NET? As a long time C++ programmer I hate to manage object lifetime myself agai开发者_开发知识库n. The Dispose-Pattern is IMHO nothing but a bad joke compared to the ease of use of RAII, especially as it forces the user to handle the implementation detail (Dispose) of an object and the class to become IDisplosable itself…
Dispose is only for unmanaged resources. For managed resources, you have to do nothing since the garbage collector takes care of it (and doesn't even allow you to do deterministic release of resources anyway).
So what exactly do you want to achieve?
精彩评论