Pinning a Type via the fixed Keyword
As you saw in the previous example, allocating a chunk of memory within an unsafe context may be
facilitated via the stackalloc keyword. By the very nature of this operation, the allocated memory
is cleaned up as soon as the allocating method has returned (as the memory is acquired from the
stack). However, assume a more complex example. During our examination of the -> operator, you
created a value type named Point. Like all value types, the allocated memory is popped off the stack
once the executing scope has terminated. For the sake of argument, assume Point was instead
defined as a
reference type:
Do'stlaringiz bilan baham: |