输出:50和18
class Class1
{
static void Main(string[] args)
{
Person pre1;
pre1.name = "张三";
pre1.sex = "男";
pre1.age = 18;
Person pre2;
pre2 = pre1;
pre1.age = 50;
Console.WriteLine(pre1.age);
Console.WriteLine(pre2.age);
Console.ReadKey();
}
}
struct Person
{
public string name;
public string sex;
public int age;
}
输出都是50;
static void Main(string[] args)
{
Person pre1 = new Person() ;
pre1.name = "张三";
pre1.sex = "男";
pre1.age = 18;
Person pre2;
pre2 = pre1;
pre1.age = 50;
Console.WriteLine(pre1.age);
Console.WriteLine(pre2.age);
Console.ReadKey();
}
}
struct Person
{
public string name;
public string sex;
public int age;
}
这是为什么呢? |