MemoryStream.Close() or MemoryStream.Dispose()

后端 未结 10 606
北海茫月
北海茫月 2020-11-29 03:19

Which one do I call?

Is it necessary to call both?

Will the other throw an exception if I have already called one of them?

10条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 03:49

    Which one do I call?

    Any of them.

    Is it necessary to call both?

    No, either one is sufficient.

    Will the other throw an exception if I have already called one of them?

    No, disposable pattern declares that subsequent calls to Dispose don't cause negative effects.

提交回复
热议问题