code_junkie

how do i read a time value and then insert it into TimeSpan variables

Nov 11th, 2011
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. string input = "08:00";
  2. DateTime time;
  3. if (!DateTime.TryParse(input, out time))
  4. {
  5. // invalid input
  6. return;
  7. }
  8.  
  9. TimeSpan timeSpan = new TimeSpan(time.Hour, time.Minute, time.Second);
  10.  
  11. TimeSpan span = new TimeSpan(days,hours,minutes,seconds,milliseonds);
  12.  
  13. DateTime time = new DateTime(year,month,day,minutes,seconds,milliseconds);
  14.  
  15. var span = new TimeSpan(hours, minutes, seconds);
  16.  
  17. var newSpan = span.Add(new TimeSpan(hours, minutes, seconds));
Add Comment
Please, Sign In to add comment