Transfering data from textbox to 2D Array <p>I am a new in C sharp and a little stupid, I have a problem with my project, hope you can help me!</p> <p>Suppose I have a textbox1 as follow (n rows x n columns):</p> <pre><code>0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 </code></pre> <p>Now I want to transfer data from this text box into an existed 2d Matrix that will store data in Integer Type.</p> <p>I tried this but it seem to not works:</p> <pre><code>private void GETNUMERICDATA() { string txt = textbox1.text; txt = txt.Replace(" ", string.Empty); for (int k = 0; k &lt; 32; k++) { for (int l = 0; l &lt; 32; l++) { for (int i = 0; i &lt; txt.Length; i++) { char chr = txt[i]; if (chr == '0') { Matrix[k, l] = (int)char.GetNumericValue('0'); } else { if (chr == '1') Matrix[k, l] = (int)char.GetNumericValue('1'); } } } } } </code></pre> <p>Anybody can help me how to do it? All your support would be highly appreciated.</p>