C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Array.Copy: This populates the elements of the target array with the elements of the source array. The two arrays are separate in memory.
SubSo: When we change the values in the source array at this point, the target array is not affected by that change.
Finally: We use a For-Each loop to display each Integer element in the target array, revealing its contents.
For Each, ForVB.NET program that uses Array.Copy
Module Module1
    Sub Main()
        ' Source array of 5 elements.
        Dim source(4) As Integer
        source(0) = 1
        source(1) = 10
        source(2) = 100
        source(3) = 1000
        source(4) = 10000
        ' Create target array and use Array.Copy.
        Dim target(4) As Integer
        Array.Copy(source, target, target.Length)
        ' Change source array after copy was made.
        source(0) = 300
        ' Display target array.
        For Each element As Integer In target
            Console.WriteLine(element)
        Next
    End Sub
End Module
Output
1
10
100
1000
10000
Tip: Using the simplest overload for the required task is ideal. But some programs are simpler overall with the complex overloads.