Emlpoyee.cs类:

 

publicclassEmployee:IDisposable
{
实现IDisposable接口#region实现IDisposable接口
/**////
///通过实现IDisposable接口释放资源
///
publicvoidDispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/**////
///释放资源实现
///
///
protectedvirtualvoidDispose(booldisposing)
{
if(!m_disposed)
{
if(disposing)
{
//Releasemanagedresources
if(db!=null)
this.db.Dispose();
if(dt!=null)
this.dt.Dispose();
this._CurrentPosition=null;
this._Department=null;
this._EmployeeCode=null;
}
//Releaseunmanagedresources
m_disposed=true;
}
}
/**////
///析构函数
///
~Employee()
{
Dispose(false);
}
privateboolm_disposed;
#endregion
}