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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With