Difference between == operator and Equals() method in C#?
问题 What is the difference between == and Equals() with example? I know that == is used to compare operator and Equals() method is used to compare content of string.So i tried // first example string s1 = "a"; string s2 = "a"; Console.Write(a.Equals(s2)); // returns true, but if I assign "b" to s2, // then result will be false // second example string s1 ="a"; string s2 ="a"; Console.Write(s1 == s2); // returns true How this is so? Both are different object references. Suppose we consider that