58 lines
1.3 KiB
C#
58 lines
1.3 KiB
C#
/*
|
|
* C# Program to Get 2 Arrays as Input and Produce a 3rd Array by Appending one to
|
|
* other
|
|
*/
|
|
using System;
|
|
|
|
class Program
|
|
{
|
|
static void Main()
|
|
{
|
|
int[] array1 = new int[5];
|
|
int[] array2 = new int[5];
|
|
int[] array3 = new int[array1.Length + array2.Length];
|
|
Console.WriteLine("Enter Any 5 Elements for the First Array :");
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
array1[i] = int.Parse(Console.ReadLine());
|
|
}
|
|
Console.WriteLine("Enter Any 5 Elements for the Second Array :");
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
array2[i] = int.Parse(Console.ReadLine());
|
|
}
|
|
Buffer.BlockCopy(array1,0,array3,0,array1.Length * sizeof(int));
|
|
Buffer.BlockCopy(array2,0,array3,array1.Length * sizeof(int),array2.Length * sizeof(int));
|
|
Console.WriteLine("Elements in the Third Array After Appending First and Second Arrays :");
|
|
foreach (int value in array3)
|
|
{
|
|
Console.WriteLine(value);
|
|
}
|
|
Console.ReadLine();
|
|
}
|
|
}
|
|
|
|
/*
|
|
Enter Any 5 Elements for the First Array :
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
Enter Any 5 Elements for the Second Array :
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
Elements in the Third Array After Appending First and Second Arrays :
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10 |