我的类中有一个sub用于将数组属性的值设置为0以外的其他值。
这是代码。
Sub New()
Dim PName As String = String.Empty
For Each p As PropertyInfo In Me.GetType().GetProperties()
If p.CanRead Then
PName = p.PropertyType.Name.ToLower
If PName.Equals("double[]") Then
With DirectCast(p.GetValue(Me, Nothing), Double())
For x As Integer = 0 To .GetLength(.Rank - 1) - 1
.SetValue(999999999, x)
Next
End With
ElseIf PName.IndexOf("double[,]") > -1 Then
With DirectCast(p.GetValue(Me, Nothing), Double(,))
For x As Integer = 0 To .GetLength(.Rank - 1) - 1
For y As Integer = 0 To .GetLength(.Rank - 2) - 1
.SetValue(999999999, y, x)
Next
Next
End With
ElseIf PName.IndexOf("double[][]") > -1 Then
With DirectCast(p.GetValue(Me, Nothing), Double()())
For x As Integer = 0 To .GetLength(.Rank - 1) - 1
For y As Integer = 0 To .GetLength(.Rank - 2) - 1
.SetValue(999999999, y, x)
Next
Next
End With
End If
End If
Next
End Sub
锯齿状阵列部分崩溃(PName.IndexOf("double[][]")
)。数组的直接进入外部数组,但我无法弄清楚如何进入内部数组。有什么建议吗?