【发布时间】:2018-05-31 06:57:35
【问题描述】:
我得到以下 MemoryAddressExtenstion 代码,它在 C# 中显示对象地址
想知道什么是
IntPtr**
和
**(IntPtr**)
谢谢
public static class MemoryAddressExtenstion
{
public static string Address(this object me)
{
unsafe
{
TypedReference tr = __makeref(me);
var ptr = **(IntPtr**)&tr;
return "0x" + ptr.ToString("X");
}
}
}
【问题讨论】:
-
你从哪里得到的代码?
-
要了解我建议您查看 C++ 中的指针,这将帮助您理解它,因为它在 C/C++ 中比在 C# 中更常见。
**表示指向指针的指针。 -
如果有人想知道
__makeref到底是什么,请看here。 -
更新了github源码
-
@MatthewWatson,谢谢我也参考了它
标签: c#