实例: 先创建类t
/*
* AUTHOR : yez
* DATE : 2014/12/17
* DESCRIBE : just a test class of reference research in csharp
*/
namespace TestCode
{
using System;
using System.Collections.Generic;
// using System.Linq;
// using System.Text;
public class t
{
public byte[] arrto;
public byte[] arrfrom;
public t()
{
Random __r = new Random();
__r.NextBytes(arrfrom = new byte[2]);
arrto = new byte[] {
0x01,0x02
};
}
}
}
测试程序:
static void Main(string[] args) {
t __tto = new t();
// t __tfrom = new t();
__tto.arrto = __tto.arrfrom;
__tto.arrfrom = null;
}
之后arrrfrom 将不再指向堆存储区中的byte数组内存单元,而由arrto字段引用。若看成指针(不知是否妥当),即arrfrom 指针已空,但arrto指针还在!接替了arrfrom!