C# sizeof 对象指针(安全上下文) [英] C# sizeof object pointer (SAFE context)
本文介绍了C# sizeof 对象指针(安全上下文)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的,虽然 sizeof(Myenum) 和 sizeof(int) 有效,但我想使用 sizeof(object),但我不想要对象的大小,而是指针的大小......仅出于便携性原因,我需要知道是 64 位指针还是 32 位指针,如果条件编译没问题,我可以避免使用 sizeof,但我不知道是否有常量来检查我们是否在 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
.
这篇关于C# sizeof 对象指针(安全上下文)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文