Results 1 to 5 of 5

Thread: Concatenating two arrays

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Posts
    15

    Concatenating two arrays

    Is there a function in VB.NET which will concatenate two arrays?

    Currently, I am using this function:

    VB Code:
    1. Private Function AppendArray(ByVal BaseArray() As Byte, ByVal Buffer() As Byte) As Byte()
    2.         If IsArray(BaseArray) = False Then
    3.             ReDim BaseArray(Buffer.Length - 1)
    4.             Buffer.CopyTo(BaseArray, 0)
    5.         Else
    6.             ReDim Preserve BaseArray(BaseArray.Length + (Buffer.Length - 1))
    7.             Buffer.CopyTo(BaseArray, BaseArray.Length - Buffer.Length)
    8.         End If
    9.         Return BaseArray
    10.     End Function

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Do you mean the function inside String Class ??
    VB Code:
    1. String.Concat(......)

  3. #3
    Junior Member Guile.NET's Avatar
    Join Date
    Mar 2003
    Location
    www.voodoochat.com
    Posts
    31
    Is there a function in VB.NET which will concatenate two arrays?
    Obviously not.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    There is overloaded function that accepts arrays of strings.

  5. #5
    Junior Member Guile.NET's Avatar
    Join Date
    Mar 2003
    Location
    www.voodoochat.com
    Posts
    31
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width