在下面的代码中,我将获得时间跨度值的列表。我需要添加所有时间跨度值,并且该值必须存储在字符串中。如何实现这一点我尝试了很多,但我找不到答案。提前致谢。
List<TimeSpan> objList = new List<TimeSpan>();
string totalIntervalTime = string.Empty;
private void Resume_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(textBox2.Text))
{
textBox3.Text = DateTime.Now.ToLongTimeString();
//objPausetmr.Tick += new EventHandler(objPausetmr_Tick);
//objPausetmr.Stop();
tmrObj.Start();
DateTime pausetime = Convert.ToDateTime(textBox2.Text);
DateTime startTime = Convert.ToDateTime(textBox3.Text);
TimeSpan difference = pausetime - startTime;
string intervalDifference = difference.ToString();
richTextBox1.Text = intervalDifference;
TimeSpan tltTime = TimeSpan.Zero;
objList.Add(difference);
foreach (TimeSpan tmVal in objList)
{
tltTime.Add(tmVal);
}
totalIntervalTime = tltTime.ToString();
//MessageBox.Show(interval_Time.ToString());
}
else
{
MessageBox.Show("Please set the Pause time");
}
}