我正在尝试计算两个列表框之间的时间跨度。这是我的代码。。
for (int x = 0; x < listBox1.Items.Count; x++)
{
DateTime z = DateTime.Parse(listBox2.Items.ToString());
DateTime c = DateTime.Parse(listBox3.Items.ToString());
TimeSpan w = c - z;
}
也许你需要这样的东西:
for (int x = 0; x < listBox1.Items.Count; x++)
{
DateTime z = DateTime.Parse(listBox2.Items[x].ToString());
DateTime c = DateTime.Parse(listBox3.Items[x].ToString());
TimeSpan w = c.Subtract(z);
}
此外,您的ListBoxes项目应该是相同的计数