using System;
namespace RV { class My { static void Main() { RefTypeRectangle rt1 = new RefTypeRectangle ();
rt1.Width = 10; rt1.Height = 15;
RefTypeRectangle rt2 = rt1;
Console.WriteLine ("{0},{1}",rt1.Width ,rt1.Height ); Console.WriteLine ("{0},{1}",rt2.Width ,rt2.Height );
rt1.Width = 20; rt1.Height = 30;
Console.WriteLine ("{0},{1}",rt1.Width ,rt1.Height ); Console.WriteLine ("{0},{1}","更改以后的"+rt2.Width ,rt2.Height );
Console.WriteLine ();
ValTypeRectangle vt1 = new ValTypeRectangle (); vt1.Width = 10; vt1.Height = 15; ValTypeRectangle vt2 = vt1; Console.WriteLine ("{0},{1}",vt1.Width ,vt1.Height ); Console.WriteLine ("{0},{1}",vt2.Width ,vt2.Height );
vt1.Width = 20; vt1.Height = 30;
Console.WriteLine ("{0},{1}",vt1.Width ,vt1.Height ); Console.WriteLine ("{0},{1}","更改以后的"+vt2.Width ,vt2.Height );
System.Threading .Thread .Sleep (100000); } }
class RefTypeRectangle { public int Width; public int Height; }
struct ValTypeRectangle { public int Width; public int Height; } }