gpt4 book ai didi

c# - 在派生类中实现 IDisposable

转载 作者:行者123 更新时间:2023-12-03 03:07:48 25 4
gpt4 key购买 nike

如果我有实现 IDisposable 的接口(interface)(来自 apress 书中的示例)像这样

public interface IArchitectRepository : IDisposable
{
IEnumerable<Architect> GetArchitects();
Architect GetAchitectDetails(int id);
void Create(Achitect a);
void Update(Achitect a);
void Delete(int id);
void Save();
}

如何在派生类中实现 Dispose 方法?

在书中,它保留为 NotImplementedException .

最佳答案

您没有理由以与正常情况不同的方式实现 Dispose 模式。

参见Implementing a Dispose Method

关于c# - 在派生类中实现 IDisposable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19300073/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com