1

クラスを作成してSub New()オプションを使用するとき、16個の1dおよび2dのdouble配列をループして、すべての要素を999999999に設定します。以下のコードがありますが、コンパイラーはそれを好みません。誰か助けてもらえますか?

For Each p As PropertyInfo In Me.GetType().GetProperties()
    If p.CanRead AndAlso p.PropertyType.Name.IndexOf("Double[]") > -1 Then
        For x As Integer = 0 To DirectCast(p.GetValue(Me, Nothing), Double()).GetLength - 1
            'code to set array element = 999999999
        Next
    End If
Next
4

1 に答える 1

0

複数の次元を持つ可能性のある配列で GetLength を使用する場合は、次元を指定する必要があります。

変化する:

For x As Integer = 0 To DirectCast(p.GetValue(Me, Nothing), Double()).GetLength - 1

For x As Integer = 0 To DirectCast(p.GetValue(Me, Nothing), Double()).GetLength(0) - 1

そうしないと、コンパイルされません。

于 2013-02-28T05:09:59.793 に答える