我觉得我在这里做了一些奇怪的事情,或者说我只是不太了解但是我仍然坚持用另一个阵列(大小2)填充我的arraylist。
我最初用Java编程,我认为这可以在Visual Basic中工作,但我找不到解决方案。所以我来了!
手头的问题: 我有两个2D数组,我需要取数组中每个部分的平均值。 我遍历两个数组并执行一些(简单)数学运算。但是,当它结束时,我得到一个数组,里面填满了最后计算的答案。
我在这里做错了什么? 我正在使用Microsoft Visual Studio Express 2013
以下是提供两个数组组合的代码:
Private Sub btnCombine_Click(sender As Object, e As EventArgs) Handles btnCombine.Click
'A safety to assure that the for loop will loop until the length of the
smallest array
If (dScanListMusic1.Count < dScanListMusic2.Count) Then
combineCounter = dScanListMusic1.Count
Else
combineCounter = dScanListMusic2.Count
End If
For i As Integer = 0 To combineCounter - 1
For j As Integer = 0 To 1
'Taking the average of the two doubles
joinedAverage = (dScanListMusic1(i)(j) + dScanListMusic2(i)(j)) / 2
dScanListMusicCombinedRow(j) = joinedAverage
Next
dScanListMusicCombined.Add(dScanListMusicCombinedRow)
Next