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.
  • 相关阅读:
    Oracle基础知识
    tomcat服务器
    jquery实现常用UI布局
    css画布
    css布局
    jquery快速常用技能
    css快速浏览
    css选择器
    spring boot项目mybatis配置注解+配置文件
    sass的安装和基础语法
  • 原文地址:https://www.cnblogs.com/dennysong/p/5436327.html
Copyright © 2011-2022 走看看