C# - Input string was not in a correct format
<p>I am working on a simple windows forms application that the user enters a string with delimiters and I parse the string and only get the variables out of the string.
So for example if the user enters: </p>

<pre><code>2X + 5Y + z^3
</code></pre>

<p>I extract the values 2,5 and 3 from the "equation" and simply add them together.</p>

<p>This is how I get the integer values from a string.</p>

<pre><code>int thirdValue
string temp;
temp = Regex.Match(variables[3], @"\d+").Value
thirdValue = int.Parse(temp);
</code></pre>

<p>"variables" is just an array of strings I use to store strings after parsing.</p>

<p>However, I get an error saying, "Input string was not in a correct format" when I run the application.</p>
