Herfried,
Note that the performance of 'Buffer.BlockCopy' is better than those of
'Array.CopyTo', and the OP asked for a fast solution.
I thought let me make a sample to show how right Herfried is in his answer,
your sample is almost 0,0015 times faster. You can try it, the sample that
does 100.000.000 loops needs depending on the computer 1 to 5 minutes I
assume. On your fast computer probably less than 2 minutes.
\\\
Public Module My
Sub Main()
Dim a1() As Byte = {1, 2, 3, 4, 5}
Dim a2() As Byte = {6, 7, 8, 9, 10}
Dim a(a1.Length + a2.Length - 1) As Byte
For y As Integer = 0 To 9
Dim steps As Integer = 10000000
Dim test1 As Integer = Environment.TickCount
For i As Integer = 0 To steps
Buffer.BlockCopy(a1, 0, a, 0, a1.Length)
Buffer.BlockCopy(a2, 0, a, a1.Length, a2.Length)
Next
test1 = Environment.TickCount - 1
Dim test2 As Integer = Environment.TickCount
For i As Integer = 0 To steps
a1.CopyTo(a, 0)
a2.CopyTo(a, a1.Length)
Next
test2 = Environment.TickCount - 1
Console.Write("Methode as provided by Herfried = " _
& (1 - test1 / test2).ToString & " faster than from Cor" &
vbCrLf)
Next
End Sub
End Module
Methode as provided by Herfried = 0,00146132917613373 faster than from Cor
Methode as provided by Herfried = 0,0014760397359268 faster than from Cor
Methode as provided by Herfried = 0,00147880838629866 faster than from Cor
Methode as provided by Herfried = 0,00146455792061673 faster than from Cor
Methode as provided by Herfried = 0,0014618244886111 faster than from Cor
Methode as provided by Herfried = 0,00144730673970261 faster than from Cor
Methode as provided by Herfried = 0,00146229155713606 faster than from Cor
Methode as provided by Herfried = 0,00144781823316897 faster than from Cor
Methode as provided by Herfried = 0,00145100055903713 faster than from Cor
///
You don't mind that I keep it in this newsgroup for the method, which is for
me easier to remember and less characters to write.
Cor