gpt4 book ai didi

c# - 对于明显有效的格式,TimeSpan.ParseExact() 返回 false

转载 作者:太空狗 更新时间:2023-10-30 00:26:01 30 4
gpt4 key购买 nike

为什么这段代码返回false? This question/answer strongly 暗示它应该返回 true。

TimeSpan.TryParseExact("04:00:01", "hh:mm:ss", CultureInfo.CurrentCulture, out x);

使用 InvariantCulture 也会返回 false 并且 TimeSpan.ParseExact() 会引发无效格式异常。根据上述问题,HH:mm:ss 是错误的。

04:00:01 是如何破坏 hh:mm:ss 的格式的?

最佳答案

使用 @"hh\:mm\:ss" 作为您的格式。

关于c# - 对于明显有效的格式,TimeSpan.ParseExact() 返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13920778/

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