代码如下:
using System;
class Testing : IDisposable
{
bool is_disposed = false;
protected virtual void Dispose(bool disposing)
{
if (!is_disposed) //only dispose once!
{
if (disposing)
{
Console.WriteLine( "Not in destructor, OK to reference other objects");
//perform cleanup for this object
Console.WriteLine( "Disposing....");
}
this.is_disposed = true;
} public void Disposed( ) //这里重载鸟
{
Dispose(true);
//tell the GC not to finalize
GC.SuppressFinalize(this);
} ~Testing ( )
{
Dispose(false);
Console.WriteLine("In destructor.");
}
using System;
class Testing : IDisposable
{
bool is_disposed = false;
protected virtual void Dispose(bool disposing)
{
if (!is_disposed) //only dispose once!
{
if (disposing)
{
Console.WriteLine( "Not in destructor, OK to reference other objects");
//perform cleanup for this object
Console.WriteLine( "Disposing....");
}
this.is_disposed = true;
} public void Disposed( ) //这里重载鸟
{
Dispose(true);
//tell the GC not to finalize
GC.SuppressFinalize(this);
} ~Testing ( )
{
Dispose(false);
Console.WriteLine("In destructor.");
}
解决方案 »
- 请教,关于摄像头的问题!
- C# 反射
- C#做界面如何获取C写的dll里面的printf()信息
- 一个奇怪的问题!!!托盘图标右击显示菜单,菜单变白了!!!
- log4net问题:在app.config里有二个logger:FileLogger和XmlLogger,XmlLogger怎么会继承FileLogger的appender-ref?
- 请教前辈:用.NET+C#+ACCESS能开发小型数据库管理软件吗?单机版的!
- 谁能给我点软件自动更新的中文资料?
- 关于DataGrid里对数据增删改问题!;
- C# 控制 WndProc()接收处理消息的频率
- 如何隐藏Tabpage中的某一个选项?
- 高手来帮帮忙
- 问一个几乎每个OO程序员都会碰到的关于类设计的问题:
using System;
class Testing : IDisposable
{
bool is_disposed = false;
protected virtual void Dispose(bool disposing)
{
if (!is_disposed) //only dispose once!
{
if (disposing)
{
Console.WriteLine( "Not in destructor, OK to reference other objects");
}
//perform cleanup for this object
Console.WriteLine( "Disposing....");
}
this.is_disposed = true;
} public void Disposed() //这里重载鸟
{
Dispose(true);
//tell the GC not to finalize
GC.SuppressFinalize(this);
} ~Testing ()
{
Dispose(false);
Console.WriteLine("In destructor.");
}
}为什么要先实现一个protected,然后再实现一个public的?
这种例子有还不如没有,纯粹是为了演示而演示的,啥都说明不了。