Example to copy the Array1 to Array2 and print the details in C Sharp
//file name: demo_40
//Author: SURESH BABU
//Reference: Copying of array from another array
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace demo_40
{
class Program
{
static void Main(string[] args)
{
int[,] arr1 = new int[3, 3];
int[,] arr2 = new int[3, 3];
int i, j;
// Storing User input in the Array
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
Console.WriteLine("Enter the Array Value:\t");
arr1[i, j] = Convert.ToInt32(Console.ReadLine());
}
}
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
arr2[i, j] = arr1[i, j];
}
}
Console.Write("Elements of the Array2 = {");
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
Console.Write(" {0}", arr2[i, j]);
}
}
Console.Write(" }");
Console.ReadLine();
}
}
}
//file name: demo_40
//Author: SURESH BABU
//Reference: Copying of array from another array
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace demo_40
{
class Program
{
static void Main(string[] args)
{
int[,] arr1 = new int[3, 3];
int[,] arr2 = new int[3, 3];
int i, j;
// Storing User input in the Array
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
Console.WriteLine("Enter the Array Value:\t");
arr1[i, j] = Convert.ToInt32(Console.ReadLine());
}
}
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
arr2[i, j] = arr1[i, j];
}
}
Console.Write("Elements of the Array2 = {");
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
Console.Write(" {0}", arr2[i, j]);
}
}
Console.Write(" }");
Console.ReadLine();
}
}
}
No comments:
Post a Comment