Close and Dispose - which to call?

后端 未结 7 1038
慢半拍i
慢半拍i 2020-11-22 09:38

Having read the threads Is SqlCommand.Dispose enough? and Closing and Disposing a WCF Service I am wondering for classes such as SqlConnection or one of the several classes

7条回答
  •  无人及你
    2020-11-22 09:55

    Typecast to iDisposable, and call dispose on that. That will invoke whatever method is configured as implementing "iDisposable.Dispose", regardless of what the function is named.

提交回复
热议问题