Should I Dispose() DataSet and DataTable?

前端 未结 12 1358
清酒与你
清酒与你 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 02:54

    If your intention or the context of this question is really garbage collection, then you can set the datasets and datatables to null explicitly or use the keyword using and let them go out of scope. Dispose does not do much as Tetraneutron said it earlier. GC will collect dataset objects that are no longer referenced and also those that are out of scope.

    I really wish SO forced people down voting to actually write a comment before downvoting the answer.

提交回复
热议问题