I know string is an alias of System.String
but I am unable to understand this specific behavior.
string s = "ABC";
string s1 = "AB"+"C";
String s2 = new String("ABC");
s == s1
returns true
but s == s2
returns false
.
I know string
is a reference type so the instance of s
and s1
refers two different instances but why is s==s1
true?