Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TimeSpan.ParseExact returns System.FormatException

Tags:

c#

.net

timespan

I have the following code:

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

and my input format is:

00:00:15,680

It's quite easy task I know. But I always get the following error:

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

So what I do wrong ? Can you help me with my specific task ? Actually I've already tried so many formats but unfortunately noone is correct.

like image 258
isxaker Avatar asked Nov 27 '25 03:11

isxaker


1 Answers

According to ParseExact definition, the syntax is:

input format, etc

The System.FormatException exception message is about the input parameter, the first parameter from the list that is in the function's prototype. I would double check the value of the input parameter from your code.

like image 142
Bogdan Doicin Avatar answered Nov 29 '25 16:11

Bogdan Doicin