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