Because the C # string retention mechanism, the followingCode:
String thekey1 = "xxxxxx"; string thekey2 = "xxxxxx"; if (object. referenceequals (thekey1, thekey2) {string theC = thekey1 + thekey2 ;}
Thekey1 and thekey2 point to the same address, but the following code:
Int Thea = 1; string thekey1 = "XXX" + Thea; string thekey2 = "XXX" + Thea; If (object. referenceequals (thekey1, thekey2) {string theC = thekey1 + thekey2 ;}
Thekey1, thekey2 references are not equal. Note that the string retention mechanism of c # is only for string constants.
From the above features, in fact, it is best not to use strings, especially concatenated characters, when locking, it will be ineffective.
I originally wanted to use this stitching feature to complete layer locks of different levels, but it was ineffective after tests. Other methods were used later.
PS: the retention mechanism of the string is to find whether there is any memory for the string when allocating it. If yes, it will not be allocated and will be used directly. although this mechanism can save a certain amount of space, it will cause some performance loss. If the string is too broken, it will waste space and time. the immutability of strings facilitates parallel programming. however, it is a pity that the lock mechanism does not use the content equality of strings.