Parse a single number using the "%h" custom format string.
using System; using System.Globalization; public class Example { public static void Main() { string format; TimeSpan interval; format = "%h"; try { interval = TimeSpan.ParseExact("03", format, null); Console.WriteLine(interval); } catch (FormatException) { Console.WriteLine("Bad Format for "); } catch (OverflowException) { Console.WriteLine("Overflow"); } } }