Standard TimeSpan format: g
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
TimeSpan interval1, interval2;
interval1 = new TimeSpan(7, 45, 16);
interval2 = new TimeSpan(18, 12, 38);
Console.WriteLine("{0:g} ", interval1);
Console.WriteLine(String.Format(new CultureInfo("fr-FR"), "{0:g} ", interval1));
interval1 = new TimeSpan(0, 0, 1, 14, 36);
interval2 = TimeSpan.FromTicks(2143756);
Console.WriteLine("{0:g}", interval1);
}
}
//7:45:16
//7:45:16
//0:01:14.036
Related examples in the same category