Multi Dimensional Array

An array is a data structure that allows you to store and manipulate a collection of related values under a single name. Each value in an array is identified by an index or subscript, which is a number used to differentiate between the elements.

double[] values ;

In C#, an array can hold elements of any type, including other array types. The Array class serves as the abstract base type for all array types in C#. It provides various methods and properties for working with arrays.

Multidimensional arrays

C# supports multidimensional arrays, which have more than one index or subscript. A dimension represents a direction in which you can vary the specification of the array's elements. For example, a two-dimensional array has two dimensions and uses two indexes to access its elements. The following example declares a variable to hold a two-dimensional array of office counts, for buildings 0 through 40 and floors 0 through 5.

byte[,] offices = new byte[41, 6];

The following C# program shows a simple example of how to insert values in a two dimensional array and retrieve the values from two dimensional array.

Full Source C#
using System; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int i = 0; int j = 0; string[,] strArr = new string[2, 3]; strArr[0, 0] = "First"; strArr[0, 1] = "Second"; strArr[1, 0] = "Third"; strArr[1, 1] = "Fourth"; for (i = 0; i <= strArr.GetUpperBound(0); i++) { for (j = 0; j <= strArr.GetUpperBound(0); j++) { MessageBox.Show (strArr[i, j]); } } } } }