class Program
{
static void Main(string[] args)
{
Fuck f = new Fuck(100);
f.Change(1000, ref f);
Console.Read();
}
}
struct Fuck{ public readonly int Num; public Fuck(int value) { this.Num = value; } public void Change(int value, ref Fuck data) { System.Console.WriteLine(this.Num); data = new Fuck(value); System.Console.WriteLine(this.Num); }} 结果
100
1000
------------------------------------------------------
去掉ref
class Program
{
static void Main(string[] args)
{
Fuck f = new Fuck(100);
f.Change(1000, f);
Console.Read();
}
}
struct Fuck{ public readonly int Num; public Fuck(int value) { this.Num = value; } public void Change(int value, Fuck data) { System.Console.WriteLine(this.Num); data = new Fuck(value); System.Console.WriteLine(this.Num); }} 结果
100
100
---------------------------------------------------------
class Program
{
static void Main(string[] args)
{
Fuck f = new Fuck(100);
f.Change(1000,ref f);
Console.Read();
}
}
class Fuck{ public readonly int Num; public Fuck(int value) { this.Num = value; } public void Change(int value, ref Fuck data) { System.Console.WriteLine(this.Num); data = new Fuck(value); System.Console.WriteLine(this.Num); }} 结果
100
100
这3个程序的结果无法理解
麻烦您给我讲讲