开发者

C# Method to sum hh:mm data ???

开发者 https://www.devze.com 2022-12-31 04:13 出处:网络
I want a method that will sum data that is string in the format hh:mm (time hours and minutes) 0:15 + 0:15开发者_StackOverflow社区 = 0:30Convert the strings to TimeSpans and then call the .Add method

I want a method that will sum data that is string in the format hh:mm (time hours and minutes)

0:15 + 0:15开发者_StackOverflow社区 = 0:30


Convert the strings to TimeSpans 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.

Ref: http://msdn.microsoft.com/en-us/library/system.timespan.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消