Hi,
I have this main "test" code,
{
Firm f = new Firm(0.3f);
Consumer c = new Consumer(1,f);
Console.WriteLine("First Test {0}",(c.isNull() ? "FAIL" : "OK"));
f = null;
GC.Collect();
GC.WaitForPendingFinalizers();
Console.WriteLine("Second Test {0}",(c.isNull() ? "OK" : "FAIL"));
}
The Consumer constructor do this...
public Consumer(int pId, Firm pFirm)
{
Id = pId;
myFirm = new Firm(0f);
myFirm = pFirm;
}
where myFirm is defined as "private Firm myFirm;"
and the isNull() method is like this,
public bool isNull()
{
return (myFirm==null);
}
When I run the test... y obtain,
First Test OK
Second Test FAIL
Can anyone explain to me why the second test Fail?
I understand (well I think so) that the object "f" is passed to the constructor by reference.
Thanks in advance!!!!