gpt4 book ai didi

c# DateTime.ParseExact 小数秒问题

转载 作者:太空狗 更新时间:2023-10-29 20:11:44 24 4
gpt4 key购买 nike

我有一个场景,我从文件中读取值并将其转换为 DateTime。问题是在我的时代,有时我有 5 位小数点,有时是 6 位小数点。例如,19:23:30.1234512:13:33.123456。如果我必须解析它,我不能使用 ss.fffffss.ffffff。我该怎么办?

最佳答案

尝试使用六个大写 F。根据 The F Custom Format Specifier 下的文档标题:

The number of "F" format specifiers used with the ParseExact, TryParseExact, ParseExact, or TryParseExact method indicates the maximum number of most significant digits of the seconds fraction that can be present to successfully parse the string.

关于c# DateTime.ParseExact 小数秒问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4590716/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com