TimeSpan.ParseExact returns System.FormatException

TimeSpan.ParseExact returns System.FormatException

我有以下代码:

var point = TimeSpan.ParseExact(input, "hh\:mm\:ss\,fff", CultureInfo.InvariantCulture);

我的输入格式是:

00:00:15,680

我知道这很容易。 但我总是收到以下错误:

System.FormatException: 'String was not recognized as a valid TimeSpan.'

那我做错了什么?你能帮我完成我的具体任务吗? 其实我已经尝试了很多格式,可惜没有一个是正确的。

根据ParseExact定义,语法为:

input format,等等

System.FormatException 异常消息是关于 input 参数的,它是函数原型中列表中的第一个参数。我会仔细检查您代码中 input 参数的值。