Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| // <Snippet3> | |
| using System; | |
| public class Example | |
| { | |
| public static void Main() | |
| { | |
| string value = "1.03:14:56.1667"; | |
| TimeSpan interval; | |
| try { | |
| interval = TimeSpan.ParseExact(value, "c", null); | |
| Console.WriteLine("Converted '{0}' to {1}", value, interval); | |
| } | |
| catch (FormatException) { | |
| Console.WriteLine("{0}: Bad Format", value); | |
| } | |
| catch (OverflowException) { | |
| Console.WriteLine("{0}: Out of Range", value); | |
| } | |
| if (TimeSpan.TryParseExact(value, "c", null, out interval)) | |
| Console.WriteLine("Converted '{0}' to {1}", value, interval); | |
| else | |
| Console.WriteLine("Unable to convert {0} to a time interval.", | |
| value); | |
| } | |
| } | |
| // The example displays the following output: | |
| // Converted '1.03:14:56.1667' to 1.03:14:56.1667000 | |
| // Converted '1.03:14:56.1667' to 1.03:14:56.1667000 | |
| // </Snippet3> |