Thinking of using a Multi-dimensional Array in C-sharp .
Following is the code to create or use Multi-dimensional Array in C-sharp.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MultiDimensionArray
{
class Program
{
static void Main(string[] args)
{
int[,] x = new int[3, 3];//Declaraing Multi-dimensional array
for (int j = 0; j <= 2; j++)
{
for (int k = 0; k <= 2; k++)
{
Console.WriteLine("Enter the " + (k + 1) + " element of the " + (j + 1) + " row");
x[j, k] = int.Parse(Console.ReadLine());
}
}
for (int j = 0; j <= 2; j++)
{
Console.WriteLine();
for (int k = 0; k <= 2; k++)
{
Console.Write(x[j, k] + "\t");
}
}
Console.ReadLine();
}
}
}
Following is the code to create or use Multi-dimensional Array in C-sharp.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MultiDimensionArray
{
class Program
{
static void Main(string[] args)
{
int[,] x = new int[3, 3];//Declaraing Multi-dimensional array
for (int j = 0; j <= 2; j++)
{
for (int k = 0; k <= 2; k++)
{
Console.WriteLine("Enter the " + (k + 1) + " element of the " + (j + 1) + " row");
x[j, k] = int.Parse(Console.ReadLine());
}
}
for (int j = 0; j <= 2; j++)
{
Console.WriteLine();
for (int k = 0; k <= 2; k++)
{
Console.Write(x[j, k] + "\t");
}
}
Console.ReadLine();
}
}
}
Comments
Post a Comment