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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / m.shanmuga sundaram,rjnsoftwar

There is no requirement to do this in C#. If you ask this
for in C or C++, I can write for you or we can find umpteen
number of examples in internet.But C# has the built in,time
tested functions with proper error handling. Thanks.

Is This Answer Correct ?    2 Yes 0 No

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

Answer / tester582

Thanks Shanmuga Sundaram for the answer.could you please help me by writing code without using inbuilt functions because in interviews we cannot not use inbuilt functions.

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C Sharp Interview Questions

How many bytes is an int in c#?

0 Answers  


What is default class in c#?

0 Answers  


Explain the 3 types of properties in c# with an example?

0 Answers  


What is difference between array and arraylist in c#?

0 Answers  


what is output parameter and parameter array?

1 Answers   TCS,






public void A() { int x; x = 8; x *= 4 + 8 / 2; } Given the above code, what is the value of "x"?

8 Answers  


Define assert() method? How does it work?

0 Answers   Siebel,


What is lock statement in C#?

0 Answers   B-Ways TecnoSoft,


What is the benefit of dependency injection c#?

0 Answers  


What does this keyword mean in c#?

0 Answers  


How encapsulation and abstraction defined/used in C#.NET.

8 Answers   Synechron,


What is an inheritance in c#?

0 Answers  


Categories