cSharpDonkey

cSharpDonkey

  • NA
  • 17
  • 3.3k

very noob on c# assignment : ) need help (2d array)

Nov 10 2013 11:17 PM
Hi, thanks for taking your time to read and maybe drop some knowledge -


Im making a console application that lets you order tickets for seats in the cinema.
I've been trying to make a 2d array to use for the seats, using 15 rows and 20 seats.
I can't make it work proberly and im wondering what's the better way to build this project - 
here's some things i tried:

 int[ , ] pladser = new int[15, 20];
for (int foo = 0; foo < pladser.GetLength(0); foo++ ) {                for (int bar = 0; bar < pladser.GetLength(1); bar++){                    pladser[foo, bar] = 1 + bar;
                    Console.Write(pladser[foo, bar]);
//when i write it this way the console dose not change row after last seat but writes all the 20 seats through 15 in a single line


  int[,] pladser = new int[,]
                { 
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                };
            int foo;
            foo = Convert.ToInt32(pladser);
            Console.WriteLine(foo);
//this gives me no error reports but wont write it proberly due to a system 32 message -


  int[,] pladser = new int[,]
                { 
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
                };
                for (int x = 0; x < 15; x = x++)
            {
                for (int y = 0; y < 20; y = y++)
                {


                }
                Console.Write(pladser[x, y]);
//this time i thought i finally had it but i got something wrong still and cant run the program.
//the name y does not exist - probably just an easy fix?
// Any ideas how i could get this project going would be much appreciated



Answers (14)