【发布时间】:2016-10-17 10:09:41
【问题描述】:
var time = "00:05:06,607";
string pattern = "hh:mm:ss,fff";
DateTime.TryParseExact(time, pattern, null, DateTimeStyles.None, out parsedTime);
但是TryParseExact 函数返回给我false。我还尝试了TryParse 函数,例如:
DateTime.TryParse(time, out parsedTime);
在我将时间更改为 "00:05:06.607" 之前也返回 false。但我的来源日期有很多行,例如"hh:mm:ss,fff"。
有人可以帮忙吗?
这是github上的完整项目 https://github.com/DeronLee/PhoneBook/blob/master/subtitle/MakeSubtitle.cs
【问题讨论】:
-
让我清楚你想要时间跨度或日期时间
-
在我的机器上工作 and on dotnetfiddle。请提供minimal reproducible example。
-
也为我工作。尝试使用 InvariantCulture
-
@JagadeeshGovindaraj 有什么区别?我用这个来控制字幕
-
@Heinzi 抱歉。对不起,我是 C# 的新手。我读过它并且知道什么是最小、完整和可验证的示例。它可以帮助我找出我遇到的问题。谢谢
标签: c# string winforms datetime tryparse