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

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.

Gr Cp
  • 11
  • 3

1 Answers1

0

You could use this to get a pointer to your object and use the debugger to check what you want to know:

Memory address of an object in C#

Garbage Collector basics can be looked up here:

https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/fundamentals

Christian Huber
  • 828
  • 1
  • 5
  • 20