Consider the following code snippet in C#
string s = "hi";
object k="hi".Substring(0);
// 1>
k==s // true
// 2>
Object.ReferenceEquals(s,k) //true
but when,
Object k="hii".Substring(0,2);
// 1>
k==s // false
// 2>
Object.ReferenceEquals(s,k) //false
I am having difficulty understanding why in the first case, the strings were interned while it doesn't happen so in the second case. Also it would be very helpful if anyone can point out the rules when string interning happens in c#.