Parse string to TimeSpan: "18:31.05"
using System;
public class Example
{
public static void Main()
{
string value = null;
TimeSpan interval;
value = "18:31.05";
if (TimeSpan.TryParseExact(value, @"mm\:ss\.ff", null, out interval))
Console.WriteLine("{0} --> {1}", value, interval.ToString("c"));
else
Console.WriteLine("Unable to parse '{0}'", value);
}
}
Related examples in the same category