开发者

RAII-Wrapper for .NET?

开发者 https://www.devze.com 2023-04-12 08:55 出处:网络
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

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号