C# - Protect the App to no abort
<p>My App receives a string from serial port in the format "・99,99999,99999,99999,AAAAAA,AAAAAA" every 6 seconds.
I use these statements to treat the string:</p>

<pre><code>            stringOut=stringOut.Replace("-",",");
            string[] valor_1=stringOut.Split(',');
            int i_C_AR=Convert.ToInt32(lbl_contador.Text);

            mx_02=Convert.ToInt32(valor_1[1])-Convert.ToInt32(valor_1[2]);
            mx_07=Convert.ToInt32(valor_1[2])-Convert.ToInt32(valor_1[3]);
            mx_10=Convert.ToInt32(valor_1[3]);
</code></pre>

<p>In most cases, we get the string without problems.</p>

<p>Sometimes the App aborts because of some character in the wrong place after these statements.</p>

<pre><code>mx_02=Convert.ToInt32(valor_1[1])-Convert.ToInt32(valor_1[2]);
mx_07=Convert.ToInt32(valor_1[2])-Convert.ToInt32(valor_1[3]);
mx_10=Convert.ToInt32(valor_1[3]);
</code></pre>

<p>How to protect the App to no break?</p>
