I've been going over some Microsoft samples of code for the Kinect sensor and have stumbled across the following line.
TimeSpan zeroDuration = TimeSpan.FromSeconds(0.0);
TimeSpan timeRemaining = ...;
if (timeRemaining.CompareTo(this.zeroDuration) > 0)
{
}
I understand how CompareTo()
is useful in scenarios such as sorting but why would it be used in a conditional if()
instead of the more direct approach?
if (timeRemaining > this.zeroDuration)
{
}
PS: I would take it with a grain of salt if it was from any other source but given the general quality of the code assume there is a reason
>
vsCompareTo
. – Tickler