0
public class testClass
{
testClass x = null;
public testClass()
{
x = this;
}
~testClass()
{
System.Console.WriteLine("I was destroyed");
}
}
public static class objectInMemory
{
public static int Main(string[] args)
{
testClass a = new testClass();
a = null;
System.Console.WriteLine("a=null");
System.Console.WriteLine("something");
System.Console.WriteLine("last line");
return 0;
}
}
所以..在代码中,如何在“a = null;”之后将实例化的testClass对象分配给另一个变量。例如让“b = thatObject'sAddress;”?C#,我如何找回我的对象
这不是问题,只是碰到我的脑海。
_Testclass b = a; _?但在设置为空之前。 – Steve
'a'是你的唯一参考。在'a = null'之后,你失去了它 –