zoukankan      html  css  js  c++  java
  • DataSet调用Dispose必须吗

    DataSet是一个离线托管Object

    Dispose() 是的典型被调用来释放非托管资源,例如 文件指针,流等。大部分情况,像类也会为它们暴露一个更合适的Close()方法。

    DataSet类是继承自MarshalByValueComponent. 它作为组件实现了IDisposable接口。Dispose()方法默认的任务是从父容器移除组件。但这个方法没有在System.Data.DataSet类中覆写。并且DataSet没有父容器。所以使用Dispose()方法没意义。 

    http://stackoverflow.com/questions/913228/should-i-dispose-dataset-and-datatable

    http://burnignorance.com/net-development-tips/is-it-necessary-to-call-dispose-on-a-dataset/

    Dataset is a disconnected managed object.
     
    Dispose() is typically called to release unmanaged resources such as file-pointers, streams etc. In most cases, such classes also expose a Close()method that is more appropriate for them.
     
    Dataset class is being inherited from the MarshalByValueComponent. This implements the IDisposable interface as it is a component. The default task of the Dispose() method is to remove the component from the parent container. But this method is not overridden in the System.Data.Dataset class. Also in case of Dataset there is no parent container. So use of Dispose()method has no more significance.
    Conclusion: It is not necessary to call Dispose() on Datasets. Calling the Clear() can also be appropriate.
  • 相关阅读:
    ....
    CodeForces 375A(同余)
    POJ 2377 Bad Cowtractors (最小生成树)
    POJ 1258 AgriNet (最小生成树)
    HDU 1016 Prime Ring Problem(全排列)
    HDU 4460 Friend Chains(bfs)
    POJ 2236 Wireless Network(并查集)
    POJ 2100 Graveyard Design(尺取)
    POJ 2110 Mountain Walking(二分/bfs)
    CodeForces 1059B Forgery(模拟)
  • 原文地址:https://www.cnblogs.com/dennysong/p/5436327.html
Copyright © 2011-2022 走看看