Because of the differences between the row performance and the management of internal storage resources, the type is classified as value type and reference type.
The value type directly stores the value of this type in the stack. This type is more effective than the reference type in terms of internal use and failover.
The reference type changes point to the actual target image. Therefore, you must perform an internal reference operation to retrieve the data before accessing the object. The object of the reference type must be allocated multiple bytes of internal memory to store the parameter data and the synchronization between different processes. Therefore, the demand for internal storage is huge.
Take the Data Group as an example:
Data sets reference changes of the type, so the value changes. When a data group is used as a dynamic data set, its value also changes. This is because the address of the time when the type of parameter is referenced.
Note: string is also a reference type. It is more special than struct, and its value will not automatically change during initialization.
For example: Using System;
Class Mathod
{
Static Void Printarr ( Int [] Arrlist)
{
For ( Int I = 0 ; I < Arr. length; I ++ )
{
Arrlist [I] = I;
}
}
Static Void Main ()
{
Int [] Arr = { 100 , 200 , 300 };
Printarr (ARR );
Foreach ( Int I In ARR)
{
Console. Write (I + " , " );
}
Console. Readline ();
}
}
Result 1, 2, not 100,200,300