文本框到数组声明 [英] textbox to array declaration

查看:61
本文介绍了文本框到数组声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对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 您可以轻松完成任务)。
The TextBox content (i.e. its Text property) is a string, hence you should first parse it in order to extract all the numbers (with String.Split method and Int32.TryParse you may easily accomlpish the task).


这篇关于文本框到数组声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆