我一直在寻找答案一段时间,但我无法找到它.
我特别看着this page.它说,CompareTo方法返回一个整数,表示它是否较早,相同或更晚.我明白使用它,我明白,对于较早的时间,整数是负的,因为它是0等.
但是这个整数是多少?它是否以秒,毫秒,刻度,或者什么也没有返回差异?我希望你可以帮助我,如果有人可以找到另一个这个问题的帖子,请告诉我.我真的很惊讶,我没有在这个主题上找到一个问题.
解决方法
该文档实际上是在IComparable界面页面(DateTime实现的):
http://msdn.microsoft.com/en-us/library/system.icomparable.aspx
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.