public static void Main() { Test t1 = new Test(); }
when t1 (reference variable) gets memory, at compile time or at runtime.I think it should be a work time. But when I set a breakpoint in the Main Method and Put a Watch for t1, it was null. So this means that t1 was in memory.
Please correct me if I am wrong.
Edit: I heard that static member variables are assigned at compile time.
t1 Main - ( "new Test()" ) - t1 null.
( ).
t1 (.. null) , , , . Main , , , .
t1
null
Main
.. Test1 t1 = new Test1();, , .
Test1 t1 = new Test1();
Test t1;
(, 4 , , .NET framework), ( ), Main .
t1 = new Test();
Test, t1 . , t1 Test().
: , - , , . , - . , , , (, , , ).
class Test2 { public static Test f1 = new Test(); }
Test, , Test2.
"Main" ( new Test()). , .
new Test()
Test t1 ( ), , ( , "Main" ).
Test t1
, , .
, ( ).
" " , JIT, , .
, , t1 . new Test() t1 Test .
Test
.
. :
, ...
, .
:
Main() { Test t1; t1 = new Test(); }
{execute - t1 - Why??
. . - t1 . ?
Test t1.
- t1 /.
? , RUN/RAN/Executed. , .
- ? , Reference/Pointer/Object. , null. , ?
null - - , , /.
/ new Test() , t1? β !
, , , .
, Test t1=null, , , - , Test() , .
Test t1=null
Main ( ) - - ( ), - / .
@ Static stuff: I'm trying to find out about static classes / variables and methods.
@People: Correct me if I am wrong in some place.
run the application in debug mode, F5 is basically a keyboard shortcut in visual studio. Place a breakpoint on this statement. Use F10 to go to the next statement. Moment debugger steps the next statement you will see the object being created.