Need help with addition of timestamps

L

Lars Vonderschmitt

Hi,

I am trying to do some calculation with times. I got a list of times
like "12:23" (mm:ss) and I want to take the sum of all my times and
output this to a textbox.
But I have no clue how to do this. Could anybody point me into the right
direction?

Thanks!
Lars
 
S

Sergey Bogdanov

Use time span for such tasks. Here you are a small sample for it:

TimeSpan t = TimeSpan.Parse("00:01:10"); // HH:mm:ss
TimeSpan t2 = TimeSpan.Parse("00:01:20");

string result = t.Add(t2).ToString();
 
L

Lars Vonderschmitt

Sergey said:
Use time span for such tasks. Here you are a small sample for it:

TimeSpan t = TimeSpan.Parse("00:01:10"); // HH:mm:ss
TimeSpan t2 = TimeSpan.Parse("00:01:20");

string result = t.Add(t2).ToString();

Thanks, that is exactly what I was looking for.

Lars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top