illustrates the use of a two-dimensional rectangular array : Array Dimension « Collections Data Structure « C# / C Sharp






illustrates the use of a two-dimensional rectangular array

illustrates the use of a two-dimensional rectangular array
 
/*
  illustrates the use of a two-dimensional rectangular array
*/

using System;

public class Example10_6 {

  public static void Main()  {
    const int rows = 8;
    const int columns = 8;
    string[,] chessboard = new string[rows, columns];

    chessboard[0, 0] = "White Rook";
    chessboard[1, 0] = "White Pawn";
    chessboard[2, 3] = "White King";
    chessboard[3, 5] = "Black Bishop";
    chessboard[4, 4] = "Black Pawn";
    chessboard[5, 3] = "Black King";

    for (int row = 0; row < rows; row++)
    {
      for (int column = 0; column < columns; column++)
      {
        Console.WriteLine("chessboard[" + row + ", " + column + "] = " +
          chessboard[row, column]);
      }
    }

  }

}


           
         
  








Related examples in the same category

1.Demonstrate a two-dimensional arrayDemonstrate a two-dimensional array
2.Sum the values on a diagonal of a 3x3x3 matrixSum the values on a diagonal of a 3x3x3 matrix
3.Initialize a two-dimensional arrayInitialize a two-dimensional array
4.Demonstrate jagged arraysDemonstrate jagged arrays
5.Use the Length array property on a 3-D arrayUse the Length array property on a 3-D array
6.Call GetLength for two dimenional array
7.Demonstrate Length with jagged arraysDemonstrate Length with jagged arrays
8.initialize a two-dimensional rectangular array, and use the array properties and methodsinitialize a two-dimensional rectangular array, and use the array properties and methods
9.the use of a three-dimensional rectangular arraythe use of a three-dimensional rectangular array
10.the use of a jagged arraythe use of a jagged array
11.Uses a two-dimensional array to store grades for studentsUses a two-dimensional array to store grades for students
12.Uses a jagged array to store sales figuresUses a jagged array to store sales figures
13.Multidimensional and Jagged Arrays:Jagged ArraysMultidimensional and Jagged Arrays:Jagged Arrays
14.Multi dimensional Arrays 1Multi dimensional Arrays 1
15.Catch OutOfMemoryException
16.Catch IndexOutOfRangeException Exception
17.Defines a 2D Array