MemoryStream.Close() or MemoryStream.Dispose()

后端 未结 10 621
北海茫月
北海茫月 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:54

    the following code is Stream.Dispose from reflector as you can see, you don't need to close if you dispose (which is implicit when using using)

    public void Dispose()
    {
        this.Close();
    }
    

提交回复
热议问题