wrapping MemoryStream in a using

前端 未结 6 1993
死守一世寂寞
死守一世寂寞 2020-12-17 19:14

I\'ve been told that System.IO.MemoryStream need not be wrapped in a using block because there is no underlying resource, this kinda goes against what i\'ve always

6条回答
  •  抹茶落季
    2020-12-17 19:29

    A guideline is that if it implements IDisposable then you should dispose of it. You're just working with an API and are not aware of the implementation so you've no reason to not put it in a using block.

提交回复
热议问题