0
0
C Sharp (C#)programming~30 mins

Multi-dimensional arrays in C Sharp (C#) - Mini Project: Build & Apply

Choose your learning style9 modes available
Working with Multi-dimensional Arrays in C#
📖 Scenario: Imagine you are organizing seats in a small movie theater. The theater has rows and columns of seats. You want to keep track of which seats are taken and which are free.
🎯 Goal: You will create a multi-dimensional array to represent the seats, mark some seats as taken, and then print the seating arrangement.
📋 What You'll Learn
Create a 2D array called seats with 3 rows and 4 columns
Use string values: "Free" or "Taken" to mark seats
Mark specific seats as taken using row and column indexes
Print the seating arrangement row by row
💡 Why This Matters
🌍 Real World
Multi-dimensional arrays are useful to represent grids, tables, or layouts like seating charts, game boards, or pixel maps.
💼 Career
Understanding multi-dimensional arrays helps in software development tasks involving data organization, UI layouts, and simulations.
Progress0 / 4 steps
1
Create a 3x4 multi-dimensional array
Create a 2D string array called seats with 3 rows and 4 columns. Initialize all seats with the value "Free".
C Sharp (C#)
Need a hint?

Use string[,] seats = new string[3, 4] and initialize each row with 4 "Free" strings.

2
Mark some seats as taken
Change the seat at row 0, column 1 and the seat at row 2, column 3 to "Taken".
C Sharp (C#)
Need a hint?

Use the syntax seats[row, column] = "Taken"; to mark seats.

3
Loop through the seats to prepare output
Use nested for loops with variables row and col to go through each seat in seats. Inside the inner loop, build a string called rowSeats that joins seat statuses separated by spaces for each row.
C Sharp (C#)
Need a hint?

Use seats.GetLength(0) for rows and seats.GetLength(1) for columns. Add each seat to rowSeats with a space.

4
Print the seating arrangement
Run the program to print the seating arrangement showing which seats are "Free" and which are "Taken".
C Sharp (C#)
Need a hint?

Run the program and check the console output matches the seating arrangement.