dimanche 23 juillet 2017

C#, How do I get back my object

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;
    }
}

So.. In the code, how can I assign the instantiated testClass object to another variable after "a = null;" For example let "b = thatObject'sAddress;"?

It is not a problem, just came across my mind.





Aucun commentaire:

Enregistrer un commentaire