Why in this situation ReferenceEquals method of object behaves differently?
string a= \"fg\";
string b= \"fg\";
Console.WriteLine(object.Referen
It is behaving correctly in both cases.
The reason a and b are the same string object is because the compiler has noticed that you specified the same string twice, and has reused the same string object to initialize both a and b.
This will generally happen with every string constant in your application.