Compare DateTimeOffset and return the sequence in CSharp
Description
The following code shows how to compare DateTimeOffset and return the sequence.
Example
using System;//from w ww . j a v a 2 s . co m
public class CompareTimes
{
private enum TimeComparison
{
Earlier = -1,
Same = 0,
Later = 1
};
public static void Main()
{
DateTimeOffset firstTime = new DateTimeOffset(2007, 9, 1, 6, 45, 0,
new TimeSpan(-7, 0, 0));
DateTimeOffset secondTime = firstTime;
Console.WriteLine("Comparing {0} and {1}: {2}",
firstTime, secondTime,
(TimeComparison) firstTime.CompareTo(secondTime));
}
}
The code above generates the following result.