Redim Preserve (VB.NET)

Redim Preserve (VB.NET)

    Sub Main()
        Dim a1 As Integer() = {0, 1, 2, 3, 4, 5}
        ReDim Preserve a1(6) '保留 陣列內容
        Console.WriteLine(a1(2))
        ReDim a1(2)         '沒Preserve,則捨棄原有內容
        Console.WriteLine(a1(2))

    End Sub


如有錯誤 歡迎指正