1. Reference type
Most types in the FCL (Framework) are reference types, and reference types are always allocated in the managed heap, and C # 's new operator returns the memory address of the object, which is the memory address of the object's data. When using reference types, there are the following performance issues that we must be aware of in development:
A, memory must be allocated from the managed heap (that is, each new object consumes memory, and too many objects cause memory consumption)
b, each object allocated on the heap has some additional members that must be initialized
C, other bytes in the object (set for field), always set to 0
D. A garbage collection operation may be enforced every time an object is allocated from the managed heap
So when the reference type is in our application, the performance of the application is significantly reduced.
2. Value type
The reference types are described above, and the performance of the application is degraded when each object is allocated from the managed heap. Imagine that when you initialize a number 6 with the Int32 type or use float to initialize a floating-point 6.6, the memory is allocated once, and the performance of the application is severely affected. To provide application performance, the CLR provides a lightweight type named value type.
C # Reference types and value types