Summary of the role of the fixed keyword in C

  • 2020-05-19 05:36:21
  • OfStack

Principle:

1, garbage collection mechanism, maintenance of reference information does not maintain pointer information

2. Instantiated objects of reference type are processed by garbage collection mechanism during their lifetime and may move memory

3, when an instance of a class object contains the value type, define the pointer to the value type compile error, because these are embedded in a reference type instances of value types with reference to instantiate the object's memory and movement, so the pointer value change in unwittingly, fixed keyword the job is to make the class instantiation object (not the class type itself, but one instantiation objects) in place does not move, garbage collection for special handling the instantiated object of a class


Related articles: