放置这个物体够吗?还是我需要做更多的事情? [英] Is disposing this object, enough? or do i need to do more?

查看:76
本文介绍了放置这个物体够吗?还是我需要做更多的事情?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此代码:-

using (System.Security.Cryptography.SHA256 sha2 = 
    new System.Security.Cryptography.SHA256Managed())
{ .. }

我需要放置这行代码,就在我离开该处置范围之前。或已经进行了处置调用。

Do I need to put this line of code, just BEFORE I leave that dispose scope .. or does the dispose 'call' that already.

sha2.Clear();


推荐答案

由于AFAIK的Clear()方法只是调用Dispose, using块应该足以确保释放所使用的资源。

Since AFAIK the Clear() method just calls Dispose, the using block should be enough to ensure that the resources used are released.

这篇关于放置这个物体够吗?还是我需要做更多的事情?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆