I want to set a 2 dimensional array as a property but I keep getting multiple errors when I try.

This is what I just tried. The comments are the errors.

Dim _magnitude(,) As Integer
Public Property magnitude() As Integer
    Get
        Return Me._magnitude 'Value of type '2-dimensional array of Integer' cannot be converted to 'Integer'
    End Get
    Set(ByVal value As Integer)
        Me._magnitude = value 'Value of type 'Integer' cannot be converted to '2-dimensional array of Integer'
    End Set
End Property

I'm sure the answer is really obvious, I'm new to vb.net.

有帮助吗?

解决方案

Use the type Integer(,) for the property and setter parameter:

Dim _magnitude(,) As Integer
Public Property magnitude As Integer(,)
    Get
        Return Me._magnitude
    End Get
    Set(ByVal value As Integer(,))
        Me._magnitude = value
    End Set
End Property
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top