| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 525 人关注过本帖
标题:[c#菜鸟]我想问一问IO 跟array 的一些问题
只看楼主 加入收藏
be4u
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-12-18
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
[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
wangnannan
Rank: 18Rank: 18Rank: 18Rank: 18Rank: 18
等 级:贵宾
威 望:87
帖 子:2546
专家分:9359
注 册:2007-11-3
收藏
得分:20 
代码很长啊 请指出是哪里出了问题  [以后不要写作业啦 本版块禁止求作业]

出来混,谁不都要拼命的嘛。 。拼不赢?那就看谁倒霉了。 。有机会也要看谁下手快,快的就能赢,慢。 。狗屎你都抢不到。 。还说什么拼命?
2010-12-19 08:20
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
快速回复:[c#菜鸟]我想问一问IO 跟array 的一些问题
数据加载中...
 
   



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

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