public static void Main()
{
Test t1 = new Test();
}
when will t1 (reference variable) will get memory, at compile time or run time.
I think it should be run time. But when I put a breakpoint at Main Method and Put a Watch for t1, it was null. So it means t1 was in memory.
Please correct me If I am wrong.
Edit: I heard Static Member Variables are assigned at compile time.
The reference t1 is assigned on the stack frame of the Main method – the value you assign to it (i.e. the ‘new Test()’ part) is allocated on the heap at runtime – this is why the t1 variable exists before that line has executed and is null.