非正式的、不完善的、寫著玩的、可能會引起.Net退出的方法:
namespace cscon
...{
class root
...{
public int i;
public int j;
/**//*public virtual int nuller(int a,int b)
{
return a + b;
}*/
}
class Program
...{
static void Main(string[] args)
...{
unsafe
...{
root rt = new root();
rt.i = 999;
rt.j = 888;
fixed (int* i = &rt.i)
...{
byte* b = (byte*)i;
b += 4;
int* j = (int*)b;
Console.WriteLine("rt.i:{0},rt.j:{1}", rt.i, rt.j);
Console.WriteLine("i:addr|{0:x}:{1}", (uint)i, *i);
Console.WriteLine("i:addr|{0:x}:{1}", (uint)j, *j);
(*j) = 5555;
Console.WriteLine("i:addr|{0:x}:{1}", (uint)j, *j);
Console.WriteLine("rt.i:{0},rt.j:{1}", rt.i, rt.j);
&nbs }
}
Console.Read();
}
}
}