The problem lies with the fact that the ListBox items are stored as strings. Ideally you should create a class for your rentable items something like this
class ItemForRent
{
public string Description;
public DateTime Year;
public decimal Price;
public DateTime AvailableFrom;
public DateTime AvailableTo;
public static List<ItemForRent> rentableItems()
{
return new List<ItemForRent>();
}
}
Then you could have a List<itemforrent> as a form level variable, which you can bind to your ListBox like this:
List<ItemForRent> rentableThings;
public Form1()
{
InitializeComponent();
rentableThings = ItemForRent.rentableItems();
listBox1.DataSource = rentableThings;
}
Then to get Total Price all you need do is this
public decimal GetTotalPrice()
{
return rentableThings.Sum(item => item.Price);
}
I think this is a better way to solve your problems. Hope this helps