尺寸为用户定义的类的数组不起作用

时间:2019-05-18 11:06:36

标签: visual-studio-2010 vb.net-2010

有人知道我为什么会收到错误消息吗?

  

NullReferenceExeption未处理。对象引用未设置为对象的实例。

具有以下代码

Class Test
    Private Prop1 As Double
    Public Property a() As Double
        Get
            Return Prop1
        End Get
        Set(ByVal value As Double)
            Prop1 = value
        End Set
    End Property
End Class

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim u() As Test = New Test() {}
        ReDim Preserve u(1)
        u(0).a = 2.2 ' Here is the crack: "NullReferenceExeption was unhandled. Object reference not set to an instance of an object"
        Exit Sub
    End Sub
End Class

0 个答案:

没有答案