从锯齿状数组中获取值

时间:2012-12-03 22:56:45

标签: c# .net jagged-arrays

我想创建一个程序,将学生姓名和他们的分数记录在2个科目中,并以表格格式显示,我使用锯齿状数组,如果我显示只是标记它的作品很棒,但我也想包括学生在显示的信息中输入姓名,下面是我的代码。

public void GetSquareArray()
        {
            const int STUDENTS = 1;
            const int MARKS = 2;
            string[] numbers = { "First", "Second", "Third", "Fourth", "Fifth" };
            string[][] company_details = new string[STUDENTS][];
            for (int i = 0; i < STUDENTS; i++)
            {
                company_details[i] = new string[MARKS];
                /*Console.WriteLine("Enter {0} Student Name", numbers[i]);
                company_details[i][0] = Console.ReadLine();*/ commenting this works fine
                for (int j = 0; j < MARKS; j++)
                {
                    Console.WriteLine("Enter Marks {0}:", j + 1);
                    company_details[i][j] = Console.ReadLine();
                }
            }

            for (int x = 0; x < STUDENTS; x++)
            {
                /*Console.Write("STUDENTS {0}: ", company_details[x]);*/ commenting this works fine.
                for (int y = 0; y < MARKS; y++)
                {
                    Console.Write("{0}\t", company_details[x][y]);
                }
                Console.WriteLine("");
            }
        }

任何人都可以告诉我如何在显示的信息中包含学生信息(姓名),就像它应该显示一样

Abbas: 12   12 

0 个答案:

没有答案