save the input value in a 2dimentsion array

Posted by arash on Stack Overflow See other posts from Stack Overflow or by arash
Published on 2010-12-24T06:12:17Z Indexed on 2010/12/24 8:54 UTC
Read the original article Hit count: 221

Filed under:
|
|
|

hi friends,how can i save the number that user enter in textbox in a 2 dimension array?

for example:

i have this numbers in textbox:45,78 and now i want to save 45,32 like this: array[0,0]=45 and array[0,1]=78

how can i do that?thanks,so much

edited: oh,when i entered 1,2,3,4,5,6,7,8,9 in textbox and it takes [2,2]=56

 private void button10_Click(object sender, EventArgs e)
    {
  int matrixDimention = 2;
        int[,] intValues = new int[matrixDimention + 1, matrixDimention + 1];
        string[] splitValues = textBox9.Text.Split(',');
        for (int i = 0; i < splitValues.Length; i++)
            intValues[i % (matrixDimention + 1), i % (matrixDimention + 1)] = Convert.ToInt32(splitValues[i]);
        string a=intValues[2,2].ToString();
        MessageBox.Show(a);

   }

when i take:

string a=intValues[2,1].ToString();

it shows 0

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms