DateTime.ParseExact с переменной долей секундыC#

Место общения программистов C#
Гость
DateTime.ParseExact с переменной долей секунды

Сообщение Гость »


I have to parse time given in hours, minutes, seconds and fraction of seconds. Such as

Код: Выделить всё

"15:42:58.1"
"15:42:58.21"
"15:42:58.417"
using the following code:

Код: Выделить всё

DateTime.ParseExact("15:42:58.1", "HH:mm:ss.0.f", CultureInfo.InvariantCulture);
This works with excactly one decimal. Any other nomber of decimal will cause an exception.

Question:
  • Is there a generic possibility for the number of decimals of seconds?


Источник: https://stackoverflow.com/questions/581 ... of-seconds

Вернуться в «C#»