下面的程序结果为
20
20
30
40
求解释
namespace 值与引用
{
class MyClass
{
public int var;
}
class MyStruct
{
public int var;
}
class Program
{
static void Main(string [] args)
{
MyClass ObjectA=new MyClass();
MyClass ObjectB=ObjectA;
ObjectA.var=10;
ObjectB.var=20;
MyStruct StructA=new MyStruct();
MyStruct StructB=ObjectA;
StructA.var=30;
StructB.var=40;
Console.WriteLine(ObjectA.var);
Console.WriteLine(ObjectB.var);
Console.WriteLine(StructA.var);
Console.WriteLine(StructB.var);
Console.ReadKey();
}
}
}
|
|