C#sizeof对象指针(SAFE上下文) [英] C# sizeof object pointer (SAFE context)

查看:129
本文介绍了C#sizeof对象指针(SAFE上下文)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,虽然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

感谢建议

推荐答案

使用IntPtr.Size.

参考资料:简单的方法来检查您是否在64位计算机上

这篇关于C#sizeof对象指针(SAFE上下文)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆