【问题标题】:How to set a 2 dimensional array as a property?如何将二维数组设置为属性?
【发布时间】:2014-07-01 19:46:03
【问题描述】:

我想将二维数组设置为属性,但尝试时不断出现多个错误。

这是我刚刚尝试过的。 cmets 是错误。

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 的新手。

【问题讨论】:

  • Public Property magnitude As Integer(,) 但可能有更好的存储方式
  • 谢谢!有什么更好的方法?
  • 这取决于它是什么以及它是如何使用、存储、引用的。

标签: arrays vb.net properties


【解决方案1】:

属性和setter参数使用Integer(,)类型:

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

【讨论】:

    猜你喜欢
    • 2013-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-08
    • 1970-01-01
    • 1970-01-01
    • 2012-04-07
    • 2012-12-04
    相关资源
    最近更新 更多