The use of sharing technology to effectively support a large number of fine-grained objects.
When dealing with strings in. NET, there is an important mechanism, called the string-resident mechanism, in which the use of the element pattern is used. The CLR (Common language runtime) stores a string by maintaining a table called a detention pool that contains a reference to each unique string that is declared or created programmatically in a program. Therefore, an instance of a string with a specific value is only one in the system.
The process of using the pattern in the CLR to implement string hosting: a particular data structure is maintained internally within the CLR--we can think of it as a hash table, a string that most of the hash table maintainers Create (I'm not saying everything here, because there are exceptions). The key of this hash table corresponds to the corresponding string itself, and value is the reference to the memory block assigned to the string. This hash table is created when the CLR initializes. Generally, in the process of running a program, if you need to create a STRING,CLR will try to find the same string in the hash table based on this string hash code, and if found, assign the address of the found string directly to the corresponding variable. If not, creating a string,clr in the managed heap first creates the strng in the managed heap and creates a key-value Pair--key for the string itself in the hash table. The value bit is the memory address of this newly created string, which is assigned the most weight to the response variable.
The underlying implementation of intern (String str), isinterned (String str), which is related to the Strig class and the detention pool, can be more intuitive in understanding the above process.