如何在类内的方法中更改 Reference 传递的参数的值?
IE:
Public Class Setting
Public Sub New(Optional ByRef target as String = Nothing)
_target = target
End Sub
Private Sub Go()
If Not IsNothing(_target) Then
_target = "New Value"
End If
End Sub
End Class
用法:
Dim var1 as String = "Old Value"
Dim s as New Setting(var1)
s.Go()
在 s.Go() 之后,我期望得到:
var1 = "New Value"
但我得到:
var1 = "Old Value"
谢谢