C#方法总结HH:MM数据? [英] C# Method to sum hh:mm data ???
本文介绍了C#方法总结HH:MM数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想这将总结的数据是字符串格式为hh的方法:毫米(时间小时和分钟)
I want a method that will sum data that is string in the format hh:mm (time hours and minutes)
0:15 0:15 + = 0 :30
0:15 + 0:15 = 0:30
推荐答案
转换的字符串时间跨度
和再调用。新增
方法。
Convert the strings to TimeSpan
s and then call the .Add
method.
TimeSpan s1 = TimeSpan.Parse("0:15");
TimeSpan s2 = TimeSpan.Parse("0:45");
TimeSpan s3 = s1 + s2;
// not tested; should work.
参考:的 http://msdn.microsoft.com/en-us/library/system.timespan.aspx
这篇关于C#方法总结HH:MM数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文