string s1 = "t";
string s2 = 't'.ToString();
Console.WriteLine(s1.Equals(s2)); // returning true
Console.WriteLine(object.Equals(s1, s2)); // returning true
Here it is returning same result. Now when I'm using StringBuilder it is not returning same value. What is the underneath reason?
StringBuilder s1 = new StringBuilder();
StringBuilder s2 = new StringBuilder();
Console.WriteLine(s1.Equals(s2)); // returning true
Console.WriteLine(object.Equals(s1, s2)); // returning false
Edit1: My above question answered below. But during this discussion what we find out StringBuilder doesn't have any override Equals method in its implementation. So when we call StringBuilder.Equals it actually goes to Object.Equals. So if someone calls StringBuilder.Equals and S1.Equals(S2) the result will be different.