System.FormatException: 'Input string was not in a correct format.'
<pre>foreach (string i in listBox1.Items) { if (i == content) { MessageBox.Show("already there"); isValid = false; textBox3.Text = "0"; } } if (isValid) { listBox1.Items.Add(content); a = Convert.ToInt32(content.ToString()); a++; textBox3.Text = a.ToString(); }
content.ToString()
a = Convert.ToInt32(content.ToString());
Quote:A FormatException exception can be thrown for one of the following reasons: - In a call to a method that converts a string to some other data type, the string doesn't conform to the required pattern. - A type implements the IFormattable interface, which supports format strings that define how an object is converted to its string representation, and an invalid format string is used.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)