那么字符串是引用类型,对吗?我的理解是,即使您将字符串按值通过方法传递,也会传递到堆中的字符串的引用。
所以......
String myTestValue = "NotModified";
TestMethod(myTestValue);
System.Diagnostics.Debug.Write(myTestValue); /* myTestValue = "NotModified" WTF? */
private void TestMethod(String Value)
{
Value = "test1";
}
或者
Dim myTestValue As String = "NotModified"
TestMethod(myTestValue)
Debug.Print(myTestValue) /* myTestValue = "NotModified" WTF? */
Private Sub TestMethod(ByVal Value As String)
Value = "test1"
End Sub
我错过了什么?引擎下面发生了什么?我本以为这个值会改变...
myTestValue
怎么可能会改变呢?它没有被修改啊?你究竟是怎么修改它的? - Stan