Array.Copy : Array « System « VB.Net by API






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

1.Array.BinarySearch
2.Array.Clone
3.Array.CreateInstance
4.Array.GetLowerBound
5.Array.GetUpperBound
6.Array.GetValue
7.Array.IndexOf
8.Array.LastIndexOf
9.Array.Length
10.Array.Reverse
11.Array.SetValue
12.Array.Sort