2014-05-13 37 views
0

我想設置一個2維數組作爲屬性,但當我嘗試時,我不斷收到多個錯誤。如何將2維數組設置爲屬性?

這就是我剛纔的嘗試。評論是錯誤。

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 

我相信答案真的很明顯,我是vb.net的新手。

+0

'公共財產的大小作爲整數(,)'但有可能是存儲 – Plutonix

+0

感謝一個更好的辦法!更好的方法是什麼? – alexanderd5398

+0

,它取決於它是什麼以及如何使用,存儲和引用它。 – Plutonix

回答

2

使用類型Integer(,)的屬性和setter參數:

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 
+0

非常感謝! – alexanderd5398

相關問題