Pergunta

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.

Foi útil?

Solução

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top