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.
  • 相关阅读:
    简单的使用rabbitmq的例子
    装饰者模式
    Zinterstore 命令
    策略模式
    简单工厂模式
    getFields()与getDeclaredFields()区别
    解决Jetty下EL版本冲突的问题
    网站ssl配置
    webservice 项目 配置wsdl
    js前端clone的要诀
  • 原文地址:https://www.cnblogs.com/dennysong/p/5436327.html
Copyright © 2011-2022 走看看