> private void calculateTotalCostsButton_Click(object sender, EventArgs e) > { > // Get the count of items selected by user, which is also the > // length of the following array. > int arrayLength = purchaseListBox.Items.Count; > string[] priceListItemsString = new string[arrayLength]; > decimal priceListItemsDecimal = new decimal(arrayLength); > > for (int i = 0; i < arrayLength; i++ ) > { > // Pick up the Items from the purchaseListBox and put them into an array string. > priceListItemsString[i] = purchaseListBox.Items[i].ToString(); > string oneItemString = purchaseListBox.Items[i].ToString(); > //int lengthOfString = purchaseListBox.Items[i].ToString().Length; > int lengthOfString = oneItemString.Length; > int startPosition = oneItemString.IndexOf("$") + 1; // Go 1 position past $ sign. > // Get the dollar amount string without the dollar sign. > priceListItemsString[i] = > oneItemString.Substring(startPosition, lengthOfString - startPosition); > } > > // You now have the array string containing the dollar amounts. > // Send the priceListItemsString array to BusinessClass as a parameter. > > } >Looks like you were looking for something like this, not Right():
{
// Pick up the Items from the purchaseListBox and put them into an array string.
priceListItemsString[i] = purchaseListBox.Items[i].ToString().Split('$').Last();
}
Cetin