1 Replies - 3565 Views - Last Post: 19 June 2012 - 08:25 AM Rate Topic: -----

#1 kikobaby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 10-July 10

how to calculate total time in asp.net using c#

Posted 19 June 2012 - 08:19 AM

may i know how to calculate the total time in asp.net using c# including hour, minutes, and second?

the example i could found in the Internet only add up hour and minutes.
string hour1="48:40";
string hour2 = "45:35";
 
TimeSpan ts = new TimeSpan(int.Parse(hour1.Split(':')[0]),int.Parse(hour1.Split(':')[1]),0);
TimeSpan ts1 = new TimeSpan(int.Parse(hour2.Split(':')[0]),int.Parse(hour2.Split(':')[1]),0);

TimeSpan total = ts + ts1;



and what does the [1] and [0] means? thanks

Is This A Good Question/Topic? 0
  • +

Replies To: how to calculate total time in asp.net using c#

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9497
  • View blog
  • Posts: 35,844
  • Joined: 12-June 08

Re: how to calculate total time in asp.net using c#

Posted 19 June 2012 - 08:25 AM

Read up on the string.split method. You'll see it returns an array of smaller strings using the indicated key as a delimiter. So those "[#]" are indexed array items... from a string ("48:40") broken into substrings around the ":".
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1