Chapter 34 Ex.2
I didn't have problems working on this program and understand most of what is happening - however I had a question about where some data goes.
Section of Code:
//Parse the values
string item = fields;
decimal unitPrice = decimal.Parse(fields, NumberStyles.Any);
int quantity = int.Parse(fields, NumberStyles.Any);
decimal totalPrice = decimal.Parse(fields, NumberStyles.Any);
//Try to add a 5th field, might break data
decimal rndPrice = decimal.Parse(fields, NumberStyles.Any);
//Display on gridView (Takes the variables defined above and creates an object with those values.
object values =
rndPrice.ToString("C") //5th Field
I changed the text documents to have a 5th field (decimal number). The object values now holds 5 pieces of data. I add the data to the row and expected an error (out of bounds or undefined cell).
My questions are (sorry trying to keep it simple)
What happened the the fifth field in (object)values when it was added to the valuesDataGrid.Rows? Did it enter some sort of memory loss, can the value be recovered without using (object)values? Or does C# do something else like automatically clean up the mistake and disregard it, which could be a problem if the user needed all the values. Lastly if this does result in some sort of memory loss would the 'using' statement w/ IDisposable be of any use in this case?