Callie

Callie

  • NA
  • 4
  • 2.9k

C# asp.net. Trying to convert TimeSpan into Decimal

Apr 23 2014 3:47 PM
I have the following code to add weekly timesheet (time) values to produce the weeks total

But I need to convert the outcome (lblTotal) to decimal and place in txtTotal

TimeSpan duration = TimeSpan.Parse(lbl1.Text).Add(TimeSpan.Parse(lbl2.Text).Add(TimeSpan.Parse(lbl3.Text).Add(TimeSpan.Parse(lbl4.Text).Add(TimeSpan.Parse(lbl5.Text).Add(TimeSpan.Parse(lbl6.Text))))));
            lblTotal.Text = "" + (duration);



I have tried the following:

txtTotal.Text = Convert.ToDecimal(duration).ToString("#.00");

but no matter how I change it around keep getting the 
System.TimeSpan' to type 'System.IConvertible error

Any help would be great
            

Answers (2)