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 An Interface Class?

554


What are the advantages of using assemble language programming?

512


Is a c# interface the same as a c++ abstract class?

560


What are properties in c#. Explain with an example?

472


Why reflection is used in c#?

489






Why do we need interface in c#?

496


What happens if you add duplicate elements to a set?

501


Can you declare a field readonly?

536


What is the class in c#?

483


What are class fields?

501


What are sorted lists?

496


What is the data provider name to connect to access database?

498


How many types of methods are there in c#?

519


What is a predicate in c#?

479


Explain how do you convert a value-type to a reference-type?

446