static void Main() { String str="sample"; ChangeString(ref str); } void ChangeString(ref string str) { str="New Sample"; }
在内存方面,它将创建新实例或更新现有实例,同时我们将ref指针传递给对象
c# string immutability
c# ×1
immutability ×1
string ×1