String interning?
Posted
by rkrauter
on Stack Overflow
See other posts from Stack Overflow
or by rkrauter
Published on 2010-04-24T23:40:39Z
Indexed on
2010/04/24
23:43 UTC
Read the original article
Hit count: 553
The second ReferenceEquals call returns false. Why isn't the string in s4 interned?
string s1 = "tom";
string s2 = "tom";
Console.Write(object.ReferenceEquals(s2, s1)); //true
string s3 = "tom";
string s4 = "to";
s4 += "m";
Console.Write(object.ReferenceEquals(s3, s4)); //false
© Stack Overflow or respective owner