Good suggestion.
Array.AppendAll now supports startIndex and count arguments: https://feedback.objo.dev/feature/1138
Array.AppendAll gains two range-selecting overloads alongside the existing whole-array form:
AppendAll(items As Array(Of T))
AppendAll(items As Array(Of T), startIndex As Integer)
AppendAll(items As Array(Of T), startIndex As Integer, count As Integer)
What each form does
Whole array — unchanged existing behaviour:
Var values() As Integer = [1, 2]
values.AppendAll([3, 4])
# values = [1, 2, 3, 4]
From a start index to the end of the source:
Var values() As Integer = [1]
Var extra() As Integer = [10, 20, 30, 40]
values.AppendAll(extra, 2)
# values = [1, 30, 40]
An exact half-open range [startIndex, startIndex + count):
Var values() As Integer = [1, 2]
Var extra() As Integer = [10, 20, 30, 40]
values.AppendAll(extra, 1, 2)
# values = [1, 2, 20, 30]
Notes
The methods mutate the receiver, return Void, and preserve the source elements' order.
startIndex may equal the source Count, and count may be 0 — both are valid no-ops.
A negative startIndex, a startIndex greater than the source Count, a negative count, or a range extending beyond the source raises a runtime error (IndexOutOfRangeException, or InvalidArgumentException for a negative count). The whole range is validated before the receiver is touched, so an invalid range leaves the receiver unchanged.
Self-append works with ranges too: the selected range is snapshotted first, so
Var values() As Integer = [1, 2, 3, 4]
values.AppendAll(values, 1, 2)
# values = [1, 2, 3, 4, 2, 3]
Elements are appended by reference (shallow copy) exactly as before, so no deep copy, no flattening of nested arrays.