Mam taki testowy kod:
public class Test
{
public Test(int iloscDanych)
{
ilosc = iloscDanych;
}
public int ilosc = 0;
}
public class Rozszerzony
{
public Test tescik;
public Rozszerzony(Test tesow)
{
tescik = tesow;
}
}
class Program
{
static void Main(string[] args)
{
Test rdzenny = new Test(22);
Rozszerzony rozszerzam = new Rozszerzony(rdzenny);
rdzenny = null;
if (rozszerzam.tescik == null)
Console.WriteLine("JEST NULL");
else
Console.WriteLine(rozszerzam.tescik.ilosc);
Console.ReadLine();
}
}
Myślałem, że ustawienie obiektu rdzenny na null spowoduje, że pole tescik w klsaie Rozszerzony też zostanie ustawione na null, ale tak nie jest. Jak mógłbym to osiągnąć?