Should I Dispose() DataSet and DataTable?

前端 未结 12 1361
清酒与你
清酒与你 2020-11-22 02:45

DataSet and DataTable both implement IDisposable, so, by conventional best practices, I should call their Dispose() methods.

However, from what I\'ve read so far, Da

12条回答
  •  被撕碎了的回忆
    2020-11-22 03:13

    I call dispose anytime an object implements IDisposeable. It's there for a reason.

    DataSets can be huge memory hogs. The sooner they can be marked for clean up, the better.

    update

    It's been 5 years since I answered this question. I still agree with my answer. If there is a dispose method, it should be called when you are done with the object. The IDispose interface was implemented for a reason.

提交回复
热议问题