質問

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