C# sizeof 对象指针(安全上下文)

发布于 2024-10-07 13:50:04 字数 203 浏览 0 评论 0原文

好吧,虽然 sizeof(Myenum) 和 sizeof(int) 有效,但我想使用 sizeof(object),但我不需要对象的大小,而是指针的大小......仅出于可移植性的原因,我需要要知道是 64 位指针还是 32 位指针,我可以避免使用 sizeof if 可以通过条件编译,但我不知道是否有常量来检查我们是否在 32 位系统而不是 64 位系统上

谢谢寻求建议

Ok while sizeof(Myenum) and sizeof(int) works, I would like to use sizeof(object), but I don't want the size of the object, but the size of pointer... only for portability reason, I need to know if is a 64 bit pointer or 32 bit pointer, I can avoid using sizeof if is ok with conditional compilation, but I don't know if there are constants to check if we are on a 32 bit system instead of 64 bit

Thanks for suggestions

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

海未深 2024-10-14 13:50:04

IntPtr 类型被设计为一个整数,其大小是特定于平台的。也就是说,此类实例在 32 位硬件和操作系统上预计为 32 位,在 64 位硬件和操作系统上预计为 64 位。

IntPtr 类型是一个指针,可以在 IntPtr 结构

The IntPtr type is designed to be an integer whose size is platform-specific. That is, an instance of this type is expected to be 32-bits on 32-bit hardware and operating systems, and 64-bits on 64-bit hardware and operating systems.

The IntPtr type is a pointer, found it at IntPtr Structure.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文