Module Module1

    Sub Main()
        ' Integers are value types.
        Dim Integer1 As Integer = 100
        Dim Integer2 As Integer
        Integer2 = Integer1      ' Copies the value 100 into Integer2.
        ' We end up with two copies of the
        ' same information.

        ' Arrays are reference types.
        Dim NumberArray1() As Integer = {1, 2, 3}
        Dim NumberArray2() As Integer
        NumberArray2 = NumberArray1   ' Copies the reference into NumberArray2.
        ' We end up with two variables accessing
        ' the same array!

        ' This change affects the first element of both
        ' NumberArray2 and NumberArray1.
        NumberArray2(0) = 52

        Console.WriteLine("If this is 52, then NumberArray1 is the same as NumberArray2.")
        Console.WriteLine(NumberArray1(0))
        Console.WriteLine()

        NumberArray2 = NumberArray1.Clone()  ' A duplicate copy is created.
        ' We have two copies of the array.
        NumberArray2(1) = 86
        Console.WriteLine("If this isn't 86, than cloning solved the problem.")
        Console.WriteLine(NumberArray1(1))

        Console.ReadLine()
    End Sub

End Module
