Compare two TimeSpan values in CSharp
Description
The following code shows how to compare two TimeSpan values.
Example
//from ww w . j a v a2 s. co m
using System;
class Example
{
static void Main()
{
// Define a time interval equal to two hours.
TimeSpan baseInterval = new TimeSpan( 2, 0, 0);
TimeSpan span = TimeSpan.FromSeconds(-2.5);
int result = TimeSpan.Compare(baseInterval, span);
Console.WriteLine(result);
}
}
The code above generates the following result.