In .NET, what is the specific type of object reference?

those. what is the name of a data structure like the value stored on the stack that references the object on the heap?

those. is the object reference a System.What (if anything)?

I know this is not a pointer , or is it?

I know this is an "how to" pointer.

I know this is "owned by the garbage collector."

I superstitiously believe that when creating an instance of an object (i.e. a reference type) that IL gives a command in the CLR to allocate a "control stack / pair of heap values" in memory (e.g.

...
      .locals init ([0] int32 i1,
               [1] object o1,
               [2] int64 l1)
      IL_0000:  nop
      IL_0001:  ldc.i4.4
      IL_0002:  stloc.0
      IL_0003:  newobj     instance void [mscorlib]System.Object::.ctor()
      IL_0008:  stloc.1
      IL_0009:  ldloc.0
      IL_000a:  box        [mscorlib]System.Int32
...

) , ( / ) CLR/CLI CLR- OBJECTREF DWORD ( ).

, Google.

!

+5
2

, (.. 32- x86, 64- x64). CTS, , , , .

+2

, , - - . , - .

. , , .

:

    private void TestBoxing()
    {
        int i = 52;
        object io = i;
        io = "something else";

    }

IL:

.method private hidebysig instance void  TestBoxing() cil managed
{
  // Code size       18 (0x12)
  .maxstack  1
  .locals init ([0] int32 i,
           [1] object io)
  IL_0000:  nop
  IL_0001:  ldc.i4.s   52
  IL_0003:  stloc.0
  IL_0004:  ldloc.0
  IL_0005:  box        [mscorlib]System.Int32
  IL_000a:  stloc.1
  IL_000b:  ldstr      "something else"
  IL_0010:  stloc.1
  IL_0011:  ret
} // end of method Program::TestBoxing

, .locals init ([0] int32 i, [1] object io) - , , int .


()

,

, , , 4 4- , , , int 4 12 .


(2)

, , , CLR (32 64 ), CLR . , GC, .

+4

All Articles