本文介绍了Timespan无法解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个持续时间的字符串列表。哪两个字符串 -
01:33:56:00,00:23:34:00
当我添加此列表值,我得到例外 -
无法解析TimeSpan,因为至少有一个数字组件超出范围或包含太多数字。
我正在使用它 -
I have a string list of time duration. which have two string-
"01:33:56:00","00:23:34:00"
When i adding this list value, i got exception-
The TimeSpan could not be parsed because at least one of the numeric components is out of range or contains too many digits.
I am using this-
引用:
olst.TotleQcDuration = olst.Reports.Aggregate(TimeSpan.Zero,(小计) ,t)=> subtotal.Add(TimeSpan.Parse(t.Duration)))。ToString();
我尝试过:
olst.TotleQcDuration = olst.Reports.Aggregate(TimeSpan.Zero, (subtotal, t) => subtotal.Add(TimeSpan.Parse(t.Duration))).ToString();
What I have tried:
olst.TotleQcDuration = olst.Reports.Aggregate(TimeSpan.Zero, (subtotal, t) => subtotal.Add(TimeSpan.Parse(t.Duration))).ToString();
推荐答案
[ws][-]{ d | [d.]hh:mm[:ss[.ff]] }[ws]
try
{
olst.TotleQcDuration = olst.Reports.Aggregate(TimeSpan.Zero, (subtotal, t) => subtotal.Add(TimeSpan.Parse(t.Duration))).ToString();
}
catch (OverflowException)
{
MessageBox.Show("A value in the string exceeds a legitimate value.");
}
这篇关于Timespan无法解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!