我正在尝试实现 BubbleSort。但是,我得到一个数组越界错误;这发生在第三行。有人可以向我解释发生了什么问题吗?
For i As Integer = 0 To marks.Length Step 1
For x As Integer = 0 To marks.Length - 1 Step 1
If marks(x) > marks(x + 1) Then <<< "this where the problem is"
temp = marks(x + 1)
marks(x + 1) = marks(x)
marks(x) = temp
End If
Next x
Next i
For a As Integer = 0 To marks.Length
MsgBox(marks(a))
Next