IDisposable是.net中的主动资源释放接口,它是在编程过程中经常使用到的一个接口,本文介绍一下微软在Rx.NET中提供的一系列常用的Disposable类,通过它们可以简化我们的程序代码,提高代码质量。

IDisposable:

一个简单的IDisposable接口实现如下

class DisposableObject : IDisposable
{
    private readonly string name = null;
 
    public DisposableObject(string name)
    {
        this.name = name;
    }
 
    public void Dispose()
    {
        Console.WriteLine("{0} - Disposed", this.name);
    }
}
View Code

相关文章:

  • 2022-01-31
  • 2021-07-03
  • 2021-10-12
  • 2021-12-15
  • 2022-12-23
  • 2021-06-05
猜你喜欢
  • 2021-06-13
  • 2022-12-23
  • 2021-10-26
  • 2021-05-30
  • 2021-09-06
  • 2021-12-28
  • 2022-12-23
相关资源
相似解决方案