isxaker
isxaker

Reputation: 9456

TimeSpan.ParseExact returns System.FormatException

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.

Upvotes: 3

Views: 130

Answers (1)

Bogdan Doicin
Bogdan Doicin

Reputation: 2416

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.

Upvotes: 1

Related Questions