http://codehighstreet.com/Snippets/how_to_merge_two_arrays.aspx
With Duplicates
private string[] MergeArray(string[] DestinationArray, string[] SourceArray)
{
int iSourceIndex;
int iDestinationLength = DestinationArray.Length;
if (SourceArray.Length > 0)
Array.Resize(ref DestinationArray, DestinationArray.Length + SourceArray.Length);
for (iSourceIndex = 0; iSourceIndex < SourceArray.Length ; iSourceIndex++)
{
DestinationArray[iDestinationLength + iSourceIndex] = SourceArray[iSourceIndex];
}
return DestinationArray;
}
Without Duplicates
private string[] MergeArray(string[] DestinationArray, string[] SourceArray)
{
int iSourceIndex;
int iDestinationLength = DestinationArray.Length;
if (SourceArray.Length > 0)
Array.Resize(ref DestinationArray, DestinationArray.Length + SourceArray.Length);
for (iSourceIndex = 0; iSourceIndex < SourceArray.Length ; iSourceIndex++)
{
if (Array.IndexOf(arrDestination, arrSource[iSourceLength]) == -1)
DestinationArray[iDestinationLength + iSourceIndex] = SourceArray[iSourceIndex];
}
return DestinationArray;
}
}
Array.IndexOf will do a search for the specified object on array and returns the index of the first occurrence. it will return -1 if it is not find anything on the array
Syntax