标题:[c#菜鸟]我想问一问IO 跟array 的一些问题
取消只看楼主
be4u
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-12-18
结帖率:0
已结贴  问题点数:20 回复次数:2 
[c#菜鸟]我想问一问IO 跟array 的一些问题
我正在做一个作业, 要我input(map.txt), 然后用array的方法显示出来
奈何小弟愚钝, 试了很多次也没法运行, 求各位大大帮手

这是小弟写的:

map.txt如下:
6
8
XOOXOOOO
OOOOOOOO
XOOOOOOO
OOOOOOOO
XXXXXXXX
XXXOOOXX

using

namespace CinemaBookingSystem
{
    public partial class Form1 : Form
    {
        const int buttonStartingPositionX = 40, buttonStartingPositionY = 80, buttonSizeIntegerX = 80, buttonSizeIntegerY = 40;
        const string filename = "map.txt";
        int rowInteger = 0;
        int columnInteger = 0;
        Button[,] myButtons;
        string[,] myQueue;

        public Form1()
        {
            InitializeComponent();
        }

        private void createButtons(int rowInteger, int columnInteger)
        {
            myButtons = new Button[rowInteger, columnInteger];
            for (int i = 0; i < rowInteger; i++)
            {
                for (int j = 0; j < columnInteger; j++)
                {
                    myButtons[i,j] = new Button();
                    myButtons[i,j].Size = new Size(buttonSizeIntegerX, buttonSizeIntegerY);
                    myButtons[i,j].Text = myQueue[i,j];
                    myButtons[i,j].FlatStyle = FlatStyle.Flat;
                    myButtons[i,j].Location = new Point(buttonStartingPositionX + buttonSizeIntegerX * i, buttonStartingPositionY);
                    Controls.Add(myButtons[i,j]);
                }
            }
        }

        private void readArray(string[,] X)
        {
            try
            {
                rowInteger = int.Parse(X[0,0]);
                columnInteger = int.Parse(X[1,0]);
                seatTextBox.Text = (rowInteger * columnInteger).ToString();
            }
            catch
            {
                MessageBox.Show("ERROR");
                return;
            }

            myQueue = new string[rowInteger, columnInteger];

            for (int i = 0; i < rowInteger; i++)
            {
                for (int j = 0; j < columnInteger; j++)
                {
                    myQueue[i, j] = X[(i+1),(j+1)];
                }
            }
            createButtons(rowInteger, columnInteger);
        }

        private void loadButton_Click(object sender, EventArgs e)
        {
            string[] fileContent;
            try
            {
                fileContent = File.ReadAllLines(filename); Error    1    Cannot implicitly convert type 'string[]' to 'string[*,*]'   
   

            }
            catch
            {
                MessageBox.Show("not found");
                return;
            }
            readArray(fileContent);
        }


    }
}




[ 本帖最后由 be4u 于 2010-12-19 13:59 编辑 ]
搜索更多相关主题的帖子: array 
2010-12-18 22:34
be4u
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-12-18
得分:0 
已经编辑好了

对不起 我没有注意到
2010-12-19 14:00
be4u
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-12-18
得分:0 
anyone can answer me?
2010-12-20 17:10



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-329283-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.348998 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved