The runtime identifies your literary uses of "a" and returns the same reference to all of these usages, resulting in one string object, not two as you expected.
Instead of using literals, try the following:
string A1 = new string(new char[] {'a'}); string A2 = new string(new char[] {'a'}); Calculator.AreEqual(A1, A2);
What you have presented here is known as string interning.
Further information can be found on the String.Intern page.
source share