加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – DateTime.CompareTo实际返回的整数?

发布时间:2020-12-15 03:57:50 所属栏目:百科 来源:网络整理
导读:我一直在寻找答案一段时间,但我无法找到它. 我特别看着this page.它说,CompareTo方法返回一个整数,表示它是否较早,相同或更晚.我明白使用它,我明白,对于较早的时间,整数是负的,因为它是0等. 但是这个整数是多少?它是否以秒,毫秒,刻度,或者什么也没有返回差
我一直在寻找答案一段时间,但我无法找到它.

我特别看着this page.它说,CompareTo方法返回一个整数,表示它是否较早,相同或更晚.我明白使用它,我明白,对于较早的时间,整数是负的,因为它是0等.

但是这个整数是多少?它是否以秒,毫秒,刻度,或者什么也没有返回差异?我希望你可以帮助我,如果有人可以找到另一个这个问题的帖子,请告诉我.我真的很惊讶,我没有在这个主题上找到一个问题.

解决方法

该文档实际上是在IComparable界面页面(DateTime实现的):
http://msdn.microsoft.com/en-us/library/system.icomparable.aspx

The implementation of the CompareTo(Object) method must return an Int32 that has one of three values,as shown in the following table.

Less than zero: The current instance precedes the object specified
by the CompareTo method in the sort order.

Zero: This current instance occurs in the same position in the sort order as the object specified by the CompareTo method.

Greater than zero: This current instance follows the object specified by the CompareTo method in the sort order.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读