I'm currently getting a value of a string and wanted to place it in an INT to start doing calculations.
string values e.g. is p2 = 33.7; Which is actually a temperature reading in Celsius
this is what i used to convert the p2 to INT:
value = Convert.ToInt32(p2);
tavg = val / cnter;
cnter++;
this code is what i use to place the value converted to a datagridview row cell:
todayRow.Cells[index++].Value = tavg.ToString();
this.weatherreport_dgv.Rows.Add(todayRow);
The error message given by the VS2013 is this:
"An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code Additional information: Input string was not in a correct format."
The error is pointing to the conversion of p2 to INT
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…