cybertechno
May 25th, 2005, 06:51 PM
In my application Iam using a label that shows the elapsed time.
Iam using TimeSpan Class.The TimeSpan has several constructors and Iam using the long constructor.
ts = new TimeSpan((long) (ts.Ticks*(((double) iFilesTotal/(double) iFilesProcessed) - 1))); lblTimeRemaining.Text = ts.ToString();
The result is this "00:12:23:59:6754346"
Days:Hrs:Mins:Sec:milliseconds
I dont need the milliseconds for 7 decimal places, and only 2.
What is the solution?
Can I use a String Format?If yes how? I have the following VB code but what would be the C# equivalent?
String.Format("{0}:{1}:{2}:{3}.{4}", _
ts.Days.ToString().PadLeft(2, "0"c), _
ts.Hours.ToString().PadLeft(2, "0"c), _
ts.Minutes.ToString().PadLeft(2, "0"c), _
ts.Seconds.ToString().PadLeft(2, "0"c), _
ts.Milliseconds.ToString().PadLeft(3,"0"c).Substring(0, 2))
Please help.
Iam using TimeSpan Class.The TimeSpan has several constructors and Iam using the long constructor.
ts = new TimeSpan((long) (ts.Ticks*(((double) iFilesTotal/(double) iFilesProcessed) - 1))); lblTimeRemaining.Text = ts.ToString();
The result is this "00:12:23:59:6754346"
Days:Hrs:Mins:Sec:milliseconds
I dont need the milliseconds for 7 decimal places, and only 2.
What is the solution?
Can I use a String Format?If yes how? I have the following VB code but what would be the C# equivalent?
String.Format("{0}:{1}:{2}:{3}.{4}", _
ts.Days.ToString().PadLeft(2, "0"c), _
ts.Hours.ToString().PadLeft(2, "0"c), _
ts.Minutes.ToString().PadLeft(2, "0"c), _
ts.Seconds.ToString().PadLeft(2, "0"c), _
ts.Milliseconds.ToString().PadLeft(3,"0"c).Substring(0, 2))
Please help.