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 are the types in c#?

593


What is difference between ienumerable and list in c#?

535


Can you mark static constructor with access modifiers?

641


Is namespace a class?

575


What you mean by inner exception in c#?

619






What is the difference between a field and a property in c#?

568


What is the use of functional interface?

573


What's the difference between an integer and int?

623


What are verbatim strings in c#?

575


What are delegate methods?

565


What is difference between variable and property in c#?

511


Is a valid int value?

585


Can we inherit a class with private constructor in c#?

707


What do you mean by thread safe in c#?

544


What are the boolean data types in c#?

583