C# Multidimensional Arrays

C# allows multidimensional arrays. Multi-dimensional arrays are also called rectangular array. You can declare a 2-dimensional array string as below :

string [,] arr;

An array in .NET is created from Array base class. Array is a reference type because it is created from array class. The base class for arrays in C# is the System.Array class.

System.Array is the abstract base type of all array types. Array type can’t be inherited. Array can’t be extended. There size is fixed. Private constructor and inner class is use to create it

See the example of  Multidimensional Arrays :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace _2D_Array
{
class Program
{
static void Main(string[] args)
{
int[,] a = new int[3,3];
int i, j;
for (i = 0; i <= 2; i++)
{
for (j = 0; j <= 2; j++)
{
Console.WriteLine(“enter the value“);
a[i, j] = Convert.ToInt32(Console.ReadLine());
}
}
for (i = 0; i <= 2; i++)
{
for (j = 0; j <= 2; j++)
{
Console.WriteLine(a[i, j]);
}
Console.WriteLine();
}}
}
}

OutPut : To Run The Program to see the OutPut of C# Multidimensional Arrays

 

Also Read following Tutorial :

Insert, Update, Delete In GridView Using ASP.Net C#

Pass session variable from page to page Asp.Net C#

Binding Dropdownlist With Database In Asp.Net MVC

Binding Database Values in Table Using MVC Razor

Select Insert, Update And Delete With ASP.NET MVC

Display Data in GridView Using Asp.net MVC

Validation in ASP.NET MVC Razor view

MVC WebGrid CRUD: Select Insert Edit Update and Delete inside WebGrid in ASP.Net MVC

CRUD Operation Using 3-Tier Architecture In ASP.NET

Binding Dropdownlist With Database In Asp.Net MVC

Asp.Net Image Upload in 3-Tier Architecture and store in sql database

Multiple checkbox selection value in Asp.Net C#

Leave a Reply

Your email address will not be published.