Reputation: 460058
I was sure that this would output false, but actually it outputs true:
string foo = new string("foo".ToCharArray());
Console.WriteLine(string.IsInterned(foo) != null); // true
I thought that creating it already via constructor would prevent string interning. But even using a char[]
causes it to be interned. What is the reason or what is my error in reasoning?
Upvotes: 1
Views: 206
Reputation: 108975
Literal strings are interned. And you have the literal foo
in your source code.
Upvotes: 3