本文介绍了如何在二维数组中存储文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文本框,它接受两个数字,并用逗号分隔.例如:"05,2004".
我有一个二维数组,称为整数类型的store [i] [j].
我想在ith位置存储10,在jth位置存储2010.
这样,store [0] [0]应该等于"05,2010"
到目前为止,我只是在学习和处理一维数组,
并且一直在使用以下语句从文本框中读取值.
I have a text box that takes two numbers separated by a comma. For eg: "05, 2004".
I have a two dimensional array called store[i][j] of integer type.
I would like to store 10 in ith position and 2010 in jth position.
such that, store[0][0] should be equal to "05, 2010"
So far, I''ve only been learning and dealing with one dimensionl array,
and have been using the following statement to read values from a textbox.
if (!int.TryParse(carmake.Text, out store[0]))
MessageBox.Show("type an integer ");
任何帮助将非常感激.谢谢
Any help would be much appreciated. Thanks
推荐答案
string textBox = "45,78";
int[,] values = new int[1,2];
string[] textBoxSplit = textBox.Split(',');
values[0, 0] = Convert.ToInt32(textBoxSplit[0]);
values[0, 1] = Convert.ToInt32(textBoxSplit[1]);
这篇关于如何在二维数组中存储文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!