文本框到数组声明 [英] textbox to array declaration
问题描述
我对c#编程很新,所以请耐心等待。我正在开发一个简单的小程序,它允许用户在同一个文本框中输入25个值,一旦完成,我希望能够在列表框中将这25个值显示为5个数组按5列排,我想找出数组中最大的数字。
Hi I’m fairly new to c# programming so please bear with me. I’m currently working on a "simple" little program which allows the user to enter 25 values into the same text box and once this has been done I want to be able to display this 25 values in a list box as an array of 5 row by 5 column and i want to find out the largest number in the array.
private void button1_Click(object sender, EventArgs e)
{
int arrayrows = 5;
int arraycolomns = 5;
int[,] arraytimes;
arraytimes = new int[array rows, array columns];
// list_Matrix.Items.Add(tb_First.Text);
for (int i = 0; i != 5; i++)
{
for (int j = 0; j != 5; j++)
{
array times [i,j]= Convert. To String(Tb_First.Text);
list_Matrix.Items.Add(array times[i, j].To String());
}
}
}
我试图在列表中显示数组框。但它不起作用..因为我没有找到这个我不能移动到下一部分找到其中最大的数字。任何帮助将非常感激,因为我已经打砖墙
干杯
this is what i tried for displaying the array in a list box. but it isn't working.. since i dont find this i cant move to next section of finding the largest number among them. Any help will be much appreciated as i have hit a brick wall
Cheers
推荐答案
TextBox
内容(即其Text
属性)是一个字符串,因此您应首先解析它以提取所有数字(使用String.Split
方法和Int32.TryParse
您可以轻松完成任务)。
TheTextBox
content (i.e. itsText
property) is a string, hence you should first parse it in order to extract all the numbers (withString.Split
method andInt32.TryParse
you may easily accomlpish the task).
这篇关于文本框到数组声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!