如果string是引用类型,比如 and class,那么为什么 ystr1和有str2不同的值呢?理论上,两个变量都应该引用堆上的同一个内存区域,country1以及country2
static void Main(string[] args)
{
Country country1 = new Country();
country1.x = 1;
country1.y = 2;
Console.WriteLine("Country1 {0}, {1}", country1.x, country1.y);
Country country2 = new Country();
country2 = country1;
country1.x = 3;
Console.WriteLine("Country1 {0}, {1}", country1.x, country1.y);
Console.WriteLine("Country2 {0}, {1}", country2.x, country2.y);
///////////////////
string str1;
str1 = "123";
Console.WriteLine("Str1 {0}", str1);
string str2;
str2 = str1;
str1 = "1234";
Console.WriteLine("Str1 {0}", str1);
Console.WriteLine("Str2 {0}", str2);
}




