using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TK;
namespace ConsoleTester
{
class Program
{
public class SomeRef
{
public Int32 x;
}
public struct SomeVal
{
public Int32 x;
}
static void Main(string[] args)
{
var r1 = new SomeRef(); //堆上分配
var v1 = new SomeVal(); //栈上分配,同时确保值类型字段初始化为0.
r1.x = 5;
v1.x = 6;
SomeRef r2 = r1;
r2.x = 7;
Console.WriteLine("r1.x={0}", r1.x);
Console.WriteLine("r2.x={0}", r2.x);
var v2 = v1;
v2.x = 8;
Console.WriteLine("v1.x={0}", v1.x);
Console.WriteLine("v2.x={0}", v2.x);
Console.Read();
}
}
}