[RESOLVED] Passing Array ByVal
Is there any way to pass an array so that any changes made to it are not returned?
I've always passed arrays byref, and built copies such that any changes made would be upon the copy, to prevent backward propagation errors.
But perhaps I could do it some other way?
I was hoping that ByVal might now work in Net'05, but it still acts like a ByRef when passing arrays.
For example:
Code:
Private Sub TestSortToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TestSortToolStripMenuItem.Click
Dim mArr() As Integer
ReDim mArr(5)
Dim mI As Integer
For mI = 1 To 5
mArr(0) += 1
mArr(mArr(0)) = mI
Next
Call ECHO_IT(mArr)
For mI = 1 To mArr(0)
MessageBox.Show(mArr(mI))
Next
End Sub
Private Sub ECHO_IT(ByVal mArr() As Integer)
Dim mI As Integer
For mI = 1 To mArr(0)
MessageBox.Show(mArr(mI))
mArr(mI) = 0
Next
End Sub
changes the original array.
Is there a better method to pass an array and not return any changes made upon it?
-Lou