PDA

Click to See Complete Forum and Search --> : Concatenating two arrays


guiledotNET
Mar 2nd, 2003, 08:15 AM
Is there a function in VB.NET which will concatenate two arrays?

Currently, I am using this function:


Private Function AppendArray(ByVal BaseArray() As Byte, ByVal Buffer() As Byte) As Byte()
If IsArray(BaseArray) = False Then
ReDim BaseArray(Buffer.Length - 1)
Buffer.CopyTo(BaseArray, 0)
Else
ReDim Preserve BaseArray(BaseArray.Length + (Buffer.Length - 1))
Buffer.CopyTo(BaseArray, BaseArray.Length - Buffer.Length)
End If
Return BaseArray
End Function

Pirate
Mar 2nd, 2003, 11:16 AM
Do you mean the function inside String Class ??

String.Concat(......)

Guile.NET
Mar 2nd, 2003, 11:30 AM
Is there a function in VB.NET which will concatenate two arrays?


Obviously not.

Pirate
Mar 2nd, 2003, 11:36 AM
There is overloaded function that accepts arrays of strings.

Guile.NET
Mar 2nd, 2003, 12:27 PM
Extract from MSDN:


If either of the arguments is an array reference, the method concatenates a string representing that array, instead of its members (for example, "System.String[]").


It doesn't join the indices per se, but the types; so my result is "System.Byte[] System.Byte[]".

Also, after running timers on my function, I'm not much worse off using the above method. The times returned vary between 0 and 0.015625; which isn't bad.

Thanks for your help.