开发者

C# ULONG_PTR Equivalent

I am having to pass a ULONG_PTR in unsafe code in C#.

I understand that the reason for ULONG_PTR is to allow for a single codebase for both 32bit and 64bit operating systems.

Is this a case for C#'s UIntPtr开发者_开发问答? Can I be confident when passing a .Net UIntPtr as an ULONG_PTR parameter?

Thanks!


From MSDN:

The IntPtr type is CLS-compliant, while the UIntPtr type is not. Only the IntPtr type is used in the common language runtime. The UIntPtr type is provided mostly to maintain architectural symmetry with the IntPtr type

Both types are capable of storing 32-bit and 64-bit pointers. The preferred type is IntPtr.


Based on the MSDN description of it I would say that it should be:

The UIntPtr 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜