If I have two strings with the same value, they should have the same reference, right?
here is my case:
string s1 = "aaa";
string s2 = "aaa";
Console.WriteLine(" s1: {0}; s2: {1}; equals: {2}", s1,s2, ReferenceEquals(s1, s2));
prints: s1: aaa; s2: aaa; equals: True
but take a look at this code:
string s1 = "aaa";
string s2 = new string(s1.ToCharArray());
Console.WriteLine(" s1: {0}; s2: {1}; equals: {2}", s1,s2, ReferenceEquals(s1, s2));
prints: s1: aaa; s2: aaa; equals: False
Why in the second case, the ReferenceEquals return false?