Array with sorting numbers?

Posted by Naga116 under Interview Questions on 8/23/2011 | Points: 10 | Views : 1309 | Status : [Member] | Replies : 3
I am having two arrays. I would like to copy these two arrays items in to new array without using nested loop and without duplicates
I did but that is not giving proper out put.


int[] intArray = new int[5] { 8, 10, 2, 6, 3 };
int[] intArray1=new int[6]{9,1,10,6,5,2};

Nagaraju


Responses

Posted by: SheoNarayan on: 8/23/2011 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Hi Naga,

Have a read http://msdn.microsoft.com/en-us/library/6tf1f0bc.aspx at this.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Naga116, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 8/23/2011 [Member] Starter | Points: 25

Up
0
Down
You can use LINQ operation union to create a single array then you can use OrderBy of LINQ or Array.Sort

Naga116, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gausi on: 9/2/2011 [Member] Starter | Points: 25

Up
0
Down
  int[ ] intArray = new int[5] { 8, 10, 2, 6, 3 };

int[ ] intArray1 = new int[6] { 9, 1, 10, 6, 5, 2 };

int[ ] newArray = new int[11] ;
intArray.CopyTo(newArray, 0 );
intArray1.CopyTo(newArray, intArray.Count() );


using above code you can copy two arrays items in to new array without using nested loop and without duplicates

Regards,

Gaurav Singh
(gausi)

Naga116, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response