c# code for how to merge two sorted arrays
Input : A = 2,5,8,4
B = 3,9,10,5
Output : 2,3,4,5,5,8,9,10

Answer Posted / m.shanmuga sundaram, rjnsoftwa

int[] A = {2,5,8,4};
int[] B = { 3, 9, 10, 5 };
int[] C = new int[A.Length + B.Length];

A.CopyTo(C, 0);
B.CopyTo(C, A.Length);

Array.Sort(C);

foreach (int num in C)
{
Console.WriteLine(num);
}

Is This Answer Correct ?    8 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is default c#?

699


Name some properties of thread class.

753


Is object an int c#?

692


How can i Spawn a Thread

681


What are the steps to create a webservice and consume it?

664


Explain how do I get deterministic finalization in c#?

675


What will be the output of the following code?

690


What is the meaning of console writeline in c#?

627


What is mean by c#?

681


Can fields inside a class be virtual?

718


Why do we overload constructors?

679


Explain the difference between class and interface in .net?

637


What does dbml mean?

671


What are strings in c#?

706


What is marshalling in c#?

642