gpt4 book ai didi

c# - Nodatime BclDateTimeZone EqualsImpl 抛出 NotImplementedException

转载 作者:行者123 更新时间:2023-11-30 16:57:13 25 4
gpt4 key购买 nike

Nodatime BclDateTimeZone 类中的 EqualsImpl 方法抛出一个 NotImplementedException。据记载,这种行为方式 - 有这样的原因吗?

如果测试两个使用 BclDateTimeZoneZonedDateTime 是否相等,这会导致抛出异常。

这是一个错误,它看起来不对吗?

最佳答案

It is documented to behave in this way - is there a reason for this?

是的 - 基本上很难以一般方式确定区域相等性。假设我们有两个 BclDateTimeZone 实例,它们包含两个不同的 TimeZoneInfo 值……我们可以:

  • 随便说它们不相等,即使它们逻辑上等价
  • 按 ID 比较它们(在不支持 ID 的 PCL 中不可能,在 Mono 下为什么 TimeZoneInfo.Local 的 ID 为 Local IIRC)<
  • 通过历史比较它们是否平等,这是非常昂贵的

我同意这很痛苦,我想我计划在 Noda Time 2.0 中完全删除 ZonedDateTime 上的值相等性,并使 ZonedDateTime 使用引用相等性。

如果您比较时区,更好的选择可能是使用 ZonedEqualityComparer指定您希望如何比较它们。

但是在使用 BCL 值时无法比较 ZonedDateTime 值是否相等绝对令人讨厌。我有 raised a bug为了那个原因;我正在准备 1.3.1 版本,我可能会看看是否可以在那里修复它,而不是你必须等待 2.0。

关于c# - Nodatime BclDateTimeZone EqualsImpl 抛出 NotImplementedException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26874303/

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