I have string like this:”0:385″ (first number is seconds, next numbers are milliseconds), I want to use in datagridview with sorting like numbers (not like strings) so I am trying to make DateTime from string but I am not sure how exactly do this. I know I should use method Parse (or ParseExact) but when I tried it it says “String was not recognized as a valid DateTime.”. I read some articles about that but I am not sure how exactly use IFormatProvider and next arguments.
Thanks for help
I have string like this:0:385 (first number is seconds, next numbers are milliseconds), I
Share
You could use the following:
TimeSpan.Parse("0:0:0.365")But you must format the string like this: [d.]hh:mm:ss[.ff] (The day [d] and fractional seconds [ff] are optional)
See TimeSpan.Parse Method on MSDN