I am trying calculate the timespan between two listbox. This my code..
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;
}
Maybe you need some thing like this:
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);
}
Also, your ListBoxes items should be the same count
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.