gpt4 book ai didi

.net - 谜语: When are three equal dates not equal

转载 作者:行者123 更新时间:2023-12-02 07:16:12 29 4
gpt4 key购买 nike

从三个变量开始,都是System.DateTime。

a: 10/2/2009 2:30:00 PM
b: 10/2/2009 2:30:00 PM
c: 10/2/2009 2:30:00 PM

相互比较。

a=b: True
b=c: True
c=a: True

好的,我们已经确定所有三个日期都相等。因此,当我们将它们全部转换为世界时时,我们将得到相同的结果。对吧?

a.ToUniversalTime: 10/2/2009 9:30:00 PM
b.ToUniversalTime: 10/2/2009 9:30:00 PM
c.ToUniversalTime: 10/2/2009 2:30:00 PM

那到底发生了什么?

最佳答案

来自 http://msdn.microsoft.com/en-us/library/system.datetime.touniversaltime.aspx :

Starting with the .NET Framework version 2.0, the value returned by the ToUniversalTime method is determined by the Kind property of the current DateTime object.

  • Kind == Utc - 不执行转换
  • Kind == Local or Unspecified - 根据本地时区进行转换

关于.net - 谜语: When are three equal dates not equal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/668217/

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