I thought I understood the difference between Reference and Value types. I thought that 'string' only had value-type semantics while retaining the behavior of reference types. Then I tried this, expecting to see True returned in both cases. What have I misunderstood?
string strA = "AAA";
string strB = strA;
strB = "BBB";
Console.WriteLine($"strA is {strA} and strB is {strB}");
Console.WriteLine($"The statement: strA == strA is {strA == strB} \n");
Car car1 = new Car();
car1.Horsepower = 190;
Car car2 = car1;
car2.Horsepower = 200;
Console.WriteLine($"car1.Horsepower is {car1.Horsepower} and car2.Horsepower is {car2.Horsepower}");
Console.WriteLine($"The statement: car1 == car2 is {car1 == car2}");
Output:
strA is AAA and strB is BBB
The statement: strA == strA is False
car1.Horsepower is 200 and car2.Horsepower is 200
The statement: car1 == car2 is True