Why does the ReferenceEquals object method behave differently in this situation?
string a= "fg"; string b= "fg"; Console.WriteLine(object.ReferenceEquals(a, b));
So, in this situation, it gets the result true . In case he compares the values โโof my strings, not the links. But when I write something like:
StringBuilder c = new StringBuilder("fg"); string d = c.ToString(); Console.WriteLine(object.ReferenceEquals(a, d));
In this case, it works fine and the result is false , because it compares links to my objects.
Chuck norris
source share