Jonathan. Jonathan. - 1 year ago 113 Question

Get bytes from array function in VB.NET

I need to get the bytes from an array of bytes starting at a certain index and for a certain length (4). How can I get this?

Note: I don't want to use the Array.copy sub as it is not a function. I need to put it in something like

Sub MySub(
[argument as byte()]
the_function_I_Need(Array, index, length))

Answer Source
Private Function the_function_you_need(ByVal arr As Byte(), ByVal ix As Integer, _
    ByVal len As Integer) As Byte()

    Dim arr2 As Byte() = New Byte(len - 1)
    Array.Copy(arr, ix, arr2, 0, len)
    Return arr2

End Function
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download