新人报道 对象作为值传递疑惑
namespace 引用类型对象作为值参数传递_看书不能理解_{
class Myss {
public int Myss1 = 20;
}
class Program
{
static void Test(Myss f1) {
f1.Myss1 = 50;
Console.WriteLine($"After member assigment; {f1.Myss1}");
f1 = new Myss();
Console.WriteLine($"After new object creation {f1.Myss1}");
}
static void Main(string[] args)
{
Myss a1 = new Myss();
Console.WriteLine($"Before method call; {a1.Myss1}");
Test(a1);
Console.WriteLine($"afore method call; {a1.Myss1}");
Console.ReadKey();
}
}
}
为什么a.Myss1==50