18.
What will be the output of the following code
StringBuilder s1 = new StringBuilder(“Yes”); StringBuilder s2 = new StringBuilder(“Yes”); Console.WriteLine(s1 == s2); Console.WriteLine(s1.Equals(s2));
View Description
s1 and s2 are different objects hence “==” returns false, but they are equivalent hence “Equals()” method returns true. Remember there is an exception of this rule, i.e. when you use “==” operator with string class it compares value rather than identity