METHOD
TimeSpan.TryParseExact
Attempts to parse a duration according to the given format and provider; check the Boolean result. The constant c format is suitable for invariant duration text, not a local clock time.
Formal Syntax & Structure
csharp syntaxcsharp
TimeSpan.TryParseExact(text, "c", CultureInfo.InvariantCulture, out var duration)Working Example
Example Snippetcsharp
using System;using System.Globalization;Console.WriteLine(TimeSpan.TryParseExact("01:30:00", "c", CultureInfo.InvariantCulture, out var d) && d.TotalMinutes == 90); // True