我是 c# 的新手,我正在尝试处理占用大量内存的对象,因为我已经运行了内存分析并且需要处理一些资源并调用 GC 的 finalize 方法。但是 IDisposable 无法实现我的课程,这是为什么呢?我应该如何为我的班级实施 IDispose?
public class CellItem: IDisposable
{
public int MedicationDispenseId { get; set; }
public Enumerations.Timeslot Timeslot { get; set; }
public DateTime DateAdministered { get; set; }
public void dispose() {
if (this.MedicationDispenseId != null ) {
this.dispose();
}
if (this.Timeslot != null)
{
this.dispose();
}
if (this.DateAdministered != null)
{
this.dispose();
}
}
}