c# - 将字符串转换为时间跨度

标签 c#

我需要在 C# 中将我的字符串转换为时间跨度,这是我的字符串 52:13:27.0000000 当我尝试 Timespan.parse 时出现错误

The TimeSpan could not be parsed because at least one of the numeric components is out of range or contains too many digits.

求助! 谢谢

最佳答案

TimeSpan.Parse() 接受 Days:Hours:Minutes:Seconds:Miliseconds 如果你想超过 24 小时,你必须添加一天。

在您的特定情况下,它应该类似于以下内容:

TimeSpan.Parse("2:04:13:27.0000000");

关于c# - 将字符串转换为时间跨度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35098786/

相关文章:

c# - 从对象类型创建表

c# - WPF路径动画

c# - 如何检索部分存储在数据库中的日期列表并将其绑定(bind)在c#中的gridview中

C# DataGridView 虚拟模式 : Enable sorting

c# - 生成加密安全身份验证 token

c# - C# wpf 中的绑定(bind)问题

c# - 如何在 C# 中找到给定开始、结束和 2 个交点的 BezierSegment 的控制点 - 又名三次贝塞尔曲线 4 点插值

c# - Visual Studio 2012 C# 中的 mysql 连接状态

c# - OrderBy [ Descending ]() 和 SkipWhile() 的意外行为

c# - 当 WPF DataGrid 为空时显示 “No record found” 消息