Do you need to call Flush() on a stream or writer if you are using the “using” statement?

前端 未结 2 1275
刺人心
刺人心 2020-12-14 13:58

I am not sure whether I need to call Flush() on the used objects if I write something like this:

using (FileStream...)
using (CryptoStream...)
u         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-14 14:36

    As soon as you leave the using block’s scope, the stream is closed and disposed. The Close() calls the Flush(), so you should not need to call it manually.

提交回复
热议问题