Array.Copy
Imports System
Imports System.Collections
Public Class MainClass
Shared Private integerValues As Integer() = {1, 2, 3, 4, 5, 6}
Shared Private integerValuesCopy(6) As Integer
Public Shared Sub Main()
Dim result As Integer
Console.WriteLine("Initial Array Values:" )
PrintArray()
Array.Copy(integerValues, integerValuesCopy,integerValues.Length)
Console.WriteLine("Array values after Copy:" )
PrintArray()
result = Array.BinarySearch(integerValues, 5)
If result >= 0 Then
Console.WriteLine("5 found at element " & result )
Else
Console.WriteLine("5 not found" & " in integerValues")
End If
End Sub
Shared Private Sub PrintArray()
Dim integerElement As Integer
For Each integerElement In integerValues
Console.WriteLine(integerElement )
Next
Console.WriteLine(" integerValuesCopy: ")
For Each integerElement In integerValuesCopy
Console.WriteLine(integerElement )
Next
End Sub
End Class
Related examples in the same category